scheduling cron jobs on the server2
Jargon
cron is the umbrella term for the application that schedules the execution of scripts (“jobs”) on UNIX, Linux, and Solaris systems. It’s called a “command-line utility”, meaning that it’s a tool that runs in command line of your computer.
crond is the name of the program (called a “daemon”) that runs in the background and reads the relevant files used in and by the application.
cron job is another term for the job scheduled using the cron application. crontabs (or crontab file) is another term you will see, which stands for CRON TABle . This is the file which keeps the schedule of cron jobs and their times. Specifically, the schedule is the list of commands that are used to execute whatever jobs you have at whatever times you chose.
basic commands To Access a Crontab
crontab -e is used to edit or create a crontab file.
crontab -l provides a list of cronjobs, and displays the contents of the crontab file.
crontab -r removes a crontab file
crontab -v for the systems that allow it, will display the last time the crontab file was edited.
Commands to schedule a job
This takes 2 or 3 parts:
The time,
The filepath, and or
The command.
The syntax for the time is given in a format that looks like this:
0 0 * * 1-5
and combined with a filepath and command, looks like this:
0 1 * * 1-5 /me/myfilepath/myfile
And that means: at 1:00 a.m., from Monday through Friday of each week, execute myfile.
crontab syntax of date, time, and commands to run . The values can be an asterisk, or a list of elements separated by commas. Here, an element can be indicated by both singular numbers, and ranges (1, 3-5). Boundary values in ranges are inclusive.
Command to execute
The syntax is for a command or a script, and looks one of these
/mydirectory/myfolder/mycommand arg1 arg2
/mydirectory/myfolder/myscript.filetype
The myscript could also take arguments.
Arguments you might run on your Script
rm remove a file
Information you need is:
The absolute filepath of your script.
The location of your crontab file - ngl I need this too!
EXAMPLES
Steps (in Terminal) to create a job that runs daily at 2:30 a.m
crontab -e
30 2 * * * /mydirectory/myfolder/myscript.whatever
Potentially Useful Information
To adjust the MAILTO variable inside the crontab, just set it to the address you want: MAILTO = hellofriend@nomail.com