Chthontab is the name of the Linux program that inhabitants of the underworld user to schedule their tasks.
Thank you. I'm here * * * * 0-6.
A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.
Jump to
Showing posts with label crontab. Show all posts
Showing posts with label crontab. Show all posts
Crontab format (V3)
MAILTO=me@there.co.uk
# minute (0-59),
# | hour (0-23),
# | | day of the month (1-31),
# | | | month of the year (1-12),
# | | | | day of the week (0-6 with 0=Sunday).
# | | | | | commands
# 3 2,3,4 * * 0,6 /command to run on more than one day/hour
# 3 2,4-7 * * 1-5 /another/command to run on a range of days/hours
04 10 * * * /command/here 2>> /path/to/log/prog.$(date +\%Y\%m\%d).log
NOTES:
# minute (0-59),
# | hour (0-23),
# | | day of the month (1-31),
# | | | month of the year (1-12),
# | | | | day of the week (0-6 with 0=Sunday).
# | | | | | commands
# 3 2,3,4 * * 0,6 /command to run on more than one day/hour
# 3 2,4-7 * * 1-5 /another/command to run on a range of days/hours
04 10 * * * /command/here 2>> /path/to/log/prog.$(date +\%Y\%m\%d).log
NOTES:
- You must escape percent signs with a backslash
- Putting them in double quotes doesn't work
- Putting in double quotes and backslashes works, but the backslashes are written as part of the filename. So don't so that.
Email output from the crontab
method 1 - for all commands
Add this as the first line of crontab:
MAILTO=address1@host.com,address2@host.co.uk
method 2 - for specific commands
Add this line anywhere near the top:
NOTIFY_LIST="address1@host.com,address2@host.co.uk"
Use this for the command:
00 09 * * * run_command | mail -s "command has run" $NOTIFY_LIST
Errors in crontab
When your clever crontab entry doesn't work:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
You might need to escape some characters, like the percent sign: \%
Also consider that the backslash may not have the desired effect if it's inside double quotes.
Subscribe to:
Posts (Atom)