Wednesday, December 18, 2013

Cron job and Crontab entry

Crontab.

- It is used for job Scheduling
- Service name - crond

To disable user using the crontab, add entry to /etc/cron.deny file.
# vi /etc/cron.deny
  username

# service crond restart

To test if user is denied, switch to that user
# su - user
$ crontab -e
 Error is displayed [Not allowed]


Run a job at cron. Schedule to run at 10 PM for user jay
Note: either become user jay or do as root.

$ crontab -e
or
# crontab -e -u jay
  [*=mm, *=hh, *=dd, *=mm, *=Week]
00 22 * * * /bin/echo "Hello World"  >>/var/tmp/mycron
01 22 * * * /bin/date  >>/var/tmp/mycron  
  :wq

Create a cron job that restarts the server at 11:58 PM

# crontab -e
  58 23 * * * /sbin/init 6
  :wq
# service crond restart (in case to verify)

No comments:

Post a Comment