How to run cron in every second | Interview Question for Linux Administrator

How to run cron in every second | Interview Question for Linux Administrator


Question 1: how  to run cron in every second

It's not possible to run cron in every second but we can run cron in every second  using this method, we use a sleep command before the echo date.



*    *    *    *    *       echo `date -I`  >> /tmp/cron.log

*    *    *    *    *       sleep 1 ; echo `date -I`  >> /tmp/cron.log

*    *    *    *    *       sleep 2 ; echo `date -I`  >> /tmp/cron.log

*    *    *    *    *       sleep 3 ; echo `date -I`  >> /tmp/cron.log


...........
...........

*    *    *    *    *       sleep 59 ; echo `date -I`  >> /tmp/cron.log

Question 2: Differences  between cron and crontab

Cron - Cron is command name that runs scheduled action using the crond  daemon.

Crontab - crontab is file name that  containing jobs scheduled details like

*    *    *    *    *      < CMD >

*  -Minute
* - Hour
* - Day
* - Month
*  -  Day of Week ( like Sunday 0, Monday 1, Tuesday 2 and so for




Question 2 - Set cronjob to run command on every day 4:30 PM

30      16       *        *        *         /bin/bash    /opt/backup.sh

Question 3 - How to run cron after every reboot

@reboot           /bin/bash    /opt/start-vm.sh

Question 4 - deny particular user using from scheduling cron jobs?

Answer: Make entry of user in /etc/cron.deny file

Question 5 - Is required to restart cron service after any change 

Answer  - No
Previous
Next Post »