Cron and Crontab commands

The cron command starts a process that schedules command execution at specified dates and times.

crontab - maintain crontab files for individual users.Similar to other commands this to have options .
-u It specifies the name of the user whose crontab is to be tweaked.
-l The current crontab will be displayed on standard output.
-r The current crontab will be be removed.
-e This option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables.

Usage :
#crontab -u [user_name] - e
An entry under crontab for user specified by the user_name will be made and saved automatically on exiting the editor.
#crontab -u [user_name] - l
Shows the cron jobs for the user specified.

The cron jobs deceleration needs to be done in a 5 column format consisting of
  1. minute (0-59)
  2. hour (0-23)
  3. day of the month (1-31)
  4. month of the year (1-12)
  5. day of the week (0-6 with 0=Sunday)
Taking the example that if the 'root' user desires to setup a cron job,which displayes massage "Hello Jack" on the user's [Jack] terminal at 01:45 AM everyday ,the process will go like this

#crontab -u jack - e
45 01 * * * /bin/echo "Hello Saurabh"
save and exit using ':wq' if using VI editor.

Viewing the cron job to edit
#crontab -u jack - l

Deleting the cronjob
#crontab -u jack - r

Comments

Popular posts from this blog

Chrome @ Fedora

Bash Scripting Cookies

Dock the Appications