A cron schedule is a simple ASCII text file. Each user has their own cron schedule. You can edit it only with the crontab command. The default text editor is usually
viusage:
crontab -e add or edit a scheduled taskcrontab -l list the the scheduled taskscrontab -r remove all scheduled taskssyntax:
you have 6 positions, 5 for the time, 1 for the command to execute
* * * * * command_to_execute
| | | | |
| | | | |_Weekday 0-6 (0 = Sunday)
| | | |___Month 1-12
| | |_____Day 1-31
| |_______Hour 0-23 (0 = midnight)
|_________Minute 0-59
some example:
30 8 * * * rm /home/{username}/temp/*this entry remove all files in temp directory every day at 8:30 AM
5,35 * * * 1-5 rm /home/{username}/temp/*this entry remove all files in temp directory from monday to friday every hour at minute 5 and 35
30 8 * * * rm /home/{username}/temp/* >/dev/null 2>&1this is the same as the first example but with no email notification and no log file
30 8 * * * rm /home/{username}/temp/* > /home/{username}/logfiles/emptytemp.log >/dev/null 2>&1this is the same as the first example but with no email notification and the log file redirected to a custom location (
> to replace the old log file with the new one, >> to append new log file to old one)
No comments:
Post a Comment