Hi,
This is regarding issue in the cron jobs.
Issue :
When the timezone is set to UTC (or) EEST, and if we add the cron
job to run on a specified hour and minute, the cron daemon is able to
schedule the cron jobs in the specified time and works properly.
But if the timezone is set to IST and if we add the cron job to run on a
specified hour and minute, the cron daemon is not able to schedule the cron
jobs.
Issue seen with the below cronie package.
*Details :*
cronie package - cronie-1.5.1
Example scenario's using UTC timezone: (working case)
root@localhost:~$ date
Mon Nov 7 18:46:44 UTC 2016
root@localhost:~$ cat /etc/cron.d/sample
49 18 * * * root /root/cronjob1.sh
root@localhost:~$ cat /root/cronjob1.sh
#!/bin/bash
echo "`date`" >> /tmp/one
root@localhost:~$
root@localhost:~$ tailf /tmp/one
tailf: stat of /tmp/one failed: No such file or directory
root@localhost:~$ date
Mon Nov 7 18:47:59 UTC 2016
root@localhost:~$ tailf /tmp/one
tailf: stat of /tmp/one failed: No such file or directory
root@localhost:~$ date
Mon Nov 7 18:48:30 UTC 2016
root@localhost:~$ tailf /tmp/one
tailf: stat of /tmp/one failed: No such file or directory
root@localhost:~$ date
Mon Nov 7 18:49:11 UTC 2016
root@localhost:~$ tailf /tmp/one
Mon Nov 7 18:49:01 UTC 2016
Convert the UTC timezone to IST timezone, Cron jobs not working:
root@localhost:~$ date
Mon Nov 7 16:29:22 UTC 2016
root@localhost:~$ ls -lrt /etc/localtime
lrwxrwxrwx 1 root root 25 Nov 4 14:20 /etc/localtime ->
../usr/share/zoneinfo/UTC
root@localhost:~$ cp -r /etc/localtime /etc/localtime.orig
root@localhost:~$ ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
root@localhost:~$ ls -lrt /etc/localtime
lrwxrwxrwx 1 root root 32 Nov 7 22:03 /etc/localtime ->
/usr/share/zoneinfo/Asia/Kolkata
root@localhost:~$ date
Mon Nov 7 22:04:01 IST 2016
root@localhost:~$ cat /etc/cron.d/sample
14 22 * * * root /root/cronjob1.sh
root@localhost:~$ cat /root/cronjob1.sh
#!/bin/bash
echo "`date`" >> /tmp/one
root@localhost:~$
root@localhost:~$ tailf /tmp/one
Mon Nov 7 22:07:01 IST 2016
Mon Nov 7 22:08:01 IST 2016
Mon Nov 7 22:09:01 IST 2016
Mon Nov 7 22:10:01 IST 2016
Mon Nov 7 22:11:01 IST 2016
Mon Nov 7 22:12:01 IST 2016
^C
root@localhost:~$ date
Mon Nov 7 22:15:20 IST 2016
Temporary solution to the problem :
If the timezone is set to IST, and after restarting the cron service using
( systemctl restart crond.service ) everything is working normally, cron
daemon is able to schedule the jobs at specified time.
How did the restart of the cron service resolved the issue..? and how to
fix this issue permanently..?
Cron service file:
cat crond.service
[Unit]
Description=Crond Periodic Command Scheduler
[Service]
Type=oneshot
RemainAfterExit=yes
PIDFile=/var/run/cron.pid
ExecStart=/usr/sbin/crond
Restart=no
[Install]
WantedBy=multi-user.target
--
Regards,
Madhav.
+91-8123284344.