For those more bare-bones distros that don't ship with a cron daemon, I like to install cronie. This will install the binary crontab with which you can edit your user's crontab with the usual crontab -e and list it with crontab -l.
This method generates an empty crontab file, in which I like to add the following:
# +--------------------------- Minute (0-59)
# | +---------------------- Hour (0-23)
# | | +---------------- Day (1-31)
# | | | +------------ Month (1-12)
# | | | | +-------- Day of week (0-6, 0=Sunday)
# | | | | | +--- Command to be run
# | | | | | |
# v v v v v v
#====================================================================
# Uncomment for testing
# * * * * * $HOME/cron/showcronMost of us don't have the entire cron syntax memorized, and this little helper comment is always helpful!
If you're having trouble with a cronjob, and the script works when running it as your user, the problem is usually the environment / environment variables.
You can save this little script (which is also included in the above helper comment as the "testing" script - $HOME/cron/showcron):
#!/bin/bash
tag=${0##*/}
exec > /tmp/$tag.$$
echo "Generated by $tag on $(date)
Environment:"
/bin/env | /bin/sort
echo
echo '----------------------------------------------'
echo Shell settings:
set
exit 0This will generate some output under /tmp/showcron.xyz in which you can inspect the env variables available to your cron scripts at runtime.