I am running a test script where in a loop of 800, two crontab scripts create new crontab in a duration of 5 seconds.
Eg.
while [ "$counter" -lt 800 ]; do
crontab -r
create_crontab_1.sh >> cr_log.log
sleep 5;
create_crontab_2.sh>> cr_log.log
(( counter++ ))
done
Now
create_crontab_1.sh->
CRONLINE="*/2 * * * * /scratch/test1.sh >/dev/null 2>&1"
( crontab -l 2>/dev/null ; echo "${CRONLINE}" ) | crontab -
create_crontab_2.sh->
crontab cron_file.txt
cron_file.txt ->
* * * * * sleep 2; /scratch/test3.sh >/dev/null 2>&1
* * * * * sleep 3; /scratch/test4.sh >/dev/null 2>&1
/var/log/cron log:
crond[25583]: (user_name) RELOAD (/var/spool/cron/)
CROND[29339]: (root) CMD (sleep 3; /abc/test3.sh >/dev/null 2>&1)
CROND[29340]: (root) CMD (sleep 2; /abc/test4.sh >/dev/null 2>&1)
crontab[29345]: (user_name) LIST ()
CROND[29353]: (user_name) CMD (/abc/test1.sh >/dev/null 2>&1)
crontab[29365]: (user_name) REPLACE ()
Even when crontab with test1.sh gets overwritten in 5 seconds, why does test1.sh comes in cron log, and can be seen getting invoked every 2 mins (as it is scheduled to run every 2 mins) ?? Also does it have anything to do with CPU clock?
create_crontab_1.sh
andcreate_crontab_2.sh
does not appear to be shell scripts. The loop removes the crontab (with-r
) and then it runs these text files. You should see errors, yes?LIST
entry towards the end. I'm assuming this is done by you runningcrontab -l
on the command line as there is no such command in the script. There are no timestamps in the log, so it hard to tell if the log is relevant at all.