crontap is a modular, git-like and easy-to-use crontab management tool for you. (not for machines!)
sudo pip install git+https://github.com/nolze/crontap
mkdir ~/.cronmodule
or
git clone https://github.com/nolze/crontap && cd crontap
python setup.py install
mkdir ~/.cronmodule
sudo pip install git+https://github.com/nolze/crontap --upgrade
or
cd crontap && git pull -u origin master
python setup.py install --upgrade
sudo pip uninstall crontap
rm -rf ~/.cronmodule
# if you don't need them:
sudo pip uninstall Click pyyaml plaintable
Let's check the utaskun pics everyday, and save it if is updated.
$ cd some_working_dir
$ crontap init utaskun
Created module template 'utaskun' in the current working directory.
$ cd utaskun
get_utaskun.sh
#!/bin/bash
set -u
cd /tmp;
wget http://www.c.u-tokyo.ac.jp/zenki/utasukun/utaskun.gif -O utaskun.gif
find ~/Downloads/utaskun_collection/ -type f -exec md5 -q {} + | grep -sqE `md5 -q utaskun.gif`
if [[ $? != 0 ]]; then
date +'%Y%m%d' | xargs -I{} mv utaskun.gif ~/Downloads/utaskun_collection/{}.gif
echo "A new utaskun pic is found and downloaded."
else
echo "No new utaskun pic is found."
fi
cron.yaml
enabled: True
command: "./get_utaskun.sh"
schedule: "0 0 * * *" # run every midnight, if your machine is up
$ mkdir ~/Downloads/utaskun_collection
$ chmod +x get_utaskun.sh
$ ./get_utaskun.sh
...
A new utaskun pic is found and downloaded.
$ cd ..
$ crontap push utaskun
Pushed and installed module 'utaskun'.
Module Name Status Schedule
----------- ------ ---------
utaskun ON 0 0 * * *
$ crontap list
Module Name Status Schedule
----------- ------ ---------
utaskun ON 0 0 * * *
$ crontap run utaskun # try running it now
...
No new utaskun pic is found.
$ crontap run utaskun --log # with redirecting outputs to crontap logs
$ crontap enable utaskun
Enabled module 'utaskun'.
...
$ crontap disable utaskun
Disabled module 'utaskun'.
Module Name Status Schedule
----------- ------ --------
utaskun OFF
$ crontap clear # clear all modules from crontab
Cleared all crontap jobs.
$ crontap load # reflect all modules to crontab
Module Name Status Schedule
----------- ------ --------
utaskun OFF
$ crontap pull utaskun
Path 'utaskun' already exists. Overwrite? [y/N]: y
Pulled module 'utaskun' to the current working directory.
get_utaskun.rb
#!/bin/ruby
...
cron.yaml
enabled: false
command: "ruby get_utaskun.rb"
schedule: "0 0 * * *"
$ crontap push utaskun
Module 'utaskun' is already installed. Overwrite? [Y/n]:
Module Name Status Schedule
----------- ------ --------
utaskun OFF
$ crontap log utaskun
[2015-02-18 23:14:37]
No new utaskun pic is found.
$ crontap log utaskun > log.txt # save log
$ crontap log utaskun --error # show error log
...
$ crontap log utaskun --clear --error # clear error log
Cleared 'error.log'.
$ crontap remove utaskun
Removed and uninstalled module 'utaskun'.
...
$ crontap clear --hard # delete all module files
Removed and uninstalled all crontap module files.
GPLv3