![]() |
To create or edit your own personnel crontab file, use the command crontab -e. you should be in an editor defined by your $EDITOR environment variable (if not set you may be in the vi editor by default). If this is your first crontab file, you should have a blank file. Lets add something to execute every hour, on the quarter hour. Add this line.
15 * * * * echo "Test of my crontab" | mail -s "My Crontab" yourusernameNow save the file and quit your editor. Use the command crontab -l to view your crontab file.
At a quarter past the hour you should now have a new email with the subject 'My Crontab'. To remove your crontab use the crontab -r command. Note, this will remove your entire crontab file. If you would like to run a command at multiple times, say every 30 minutes instead of just once per hour, use a comma to separate the time sequences. An example of once per 1/2 hour would look like this.
15,45 * * * * echo "on the quarter hour and 3 quarter hour" | mail yourusernameTo use crontab as a weekly reminder, you could use the next example which sends me an email 15 minutes before Southpark starts on Saturday at 10 PM. The email is sent at 9:45PM.
45 21 * * 6 echo "SouthPark" | mail -s "TV SouthPark" davekFor the curious, the personnel crontabs files are located in the /var/spool/cron directory (on Redhat). These should not be edited manually in any case as the crontab deamon is notified of the changes when the crontab program edits the file.