Crontab Commandscrontab -e Edit your crontab file, or create one if it doesn't already exist. (For Mac OS X see below.) crontab -l Display your crontab file. crontab -r Remove your crontab file. crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.) For Mac OS X 10.3 (Panther) & 10.4 (Tiger) crontab -e will NOT work. You first have to cd to the /etc directory and then type sudo pico crontab at the command prompt. So to do the equivalent of crontab -e on Mac OS X first type: cd /etc and then sudo pico crontab Changing the Default Editor Except for Mac OS X, by default crontab -e will open vi. If you are not familiar with vi then you will probably want to change the default editor for crontab. But first I will explain how to exit vi. To exit vi you type :q and press enter. Then to change the default editor open your terminal and type export EDITOR=pico pico can be pico, vim, or another text editor of your choice of course. Or, for example, if you wanted to change the default editor to nano then you would type:
export EDITOR=nano NOTE: However, that when running this via SSH on my webserver that it only applies to the current session. In other words you would have to typ this everytime to login via SSH to edit crontab. Also, keep in mind that cron does not know where your home directory is OR does not see your directory structure. Be careful and specify the full path of the things you call (like /usr/java/bin/java etc.). This is not enough; in several occasions you have to add an extra line to your crontab file in order to define your HOME path. It might be something like that: HOME=/
Mailing the crontab Output By default cron saves the output in the user's mailbox (root in this case) on the local system. But you can also configure crontab to forward all output to a real email address by starting your crontab with the following line: MAILTO="
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
"
Sources:http://www.adminschoice.com/docs/crontab.htm http://kevin.vanzonneveld.net/techblog/article/schedule_tasks_on_linux_using_crontab/ http://www.lampos.net/cron-jobs http://oreilly.com/pub/a/mac/2005/11/15/terminal5.html
|