crontab: crontab is a Unix utility to schedule periodic jobs and it works in background.
crontab Options:
crontab -l The current crontab will be displayed on standard output
crontab -r The current crontab will be be removed.
crontab -e This option is used to edit the current crontab using the editor specified by the visual or editor environment variables
Crontab Fields: Crontab fields are separated by spaces and structure of the stars follows the day, month, hours and mins
- - - - -
50 23 * * * sh /home/shutm.sh (example)
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
Here I m giving the small example for scheduling the crontab job
The following example shows the request is scheduled at 11:50 p.m at every day. Crontab starts the process in background and it executes the script when scheduled time comes.
In this script I ve included the init 0 command for shut downing the machine.
Vi shutm.sh
/sbin/init 0
:wq
Here
/sbin is a standard subdirectory of the root directory in Linux and other Unix-like operating systems that contains executable (i.e., ready to run) programs
init (short for initialization) is the program on Unix and Unix-like systems that spawns all other processes and 0 represents for to shutdown the Unix machine.
No comments:
Post a Comment