Description

In this article, the reason that crontab may not work after the time zone is changed on an SRX device is explained, while also indicating that a device restart would solve the problem.

 

Symptoms

Example

Change the time zone on the SRX1500 device to PDT.

root@jtac-SRX1500> show system uptime
Current time: 2020-09-01 15:23:31 PDT
Time Source:  NTP CLOCK
System booted: 2020-09-01 13:13:04 PDT (02:10:27 ago)
Protocols started: 2020-09-01 13:14:32 PDT (02:08:59 ago)
Last configured: 2020-09-01 11:47:05 PDT (03:36:26 ago) by root
 3:23PM  up 2:10, 3 users, load averages: 0.28, 0.28, 0.29

root@jtac-SRX1500:~ # date
Tue Sep  1 15:22:56 PDT 2020

Edit crontab to execute the script /var/tmp/clear_session.sh at 15:18 PDT every day.

root@jtac-SRX1500:/var/tmp # crontab -l
SHELL=/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin

18 15 * * * sh /var/tmp/clear_session.sh

Notice that the script is not running at 15:18 at all.

 

Solution

For a time zone change to take effect for all processes running on a router or switch, you must reboot the router or switch. After rebooting the SRX device in this example, crontab is seen to run correctly.

The following log in /var/log/messages indicates that the script ran at 15:18.

Sep  1 15:18:00  jtac-SRX1500 /usr/sbin/cron[6804]: (tmp.7204) ORPHAN (no passwd entry)
Sep  1 15:18:00  jtac-SRX1500 /usr/sbin/cron[6804]: (root) RELOAD (tabs/root)
Sep  1 15:18:00  jtac-SRX1500 /usr/sbin/cron[7294]: (root) CMD (sh /var/tmp/clear_session.sh)

If you want to check how to use a script to monitor SRX device status, refer to KB21679 - How to use a script to monitor the SRX status every day/hour/minute/second [juniper.net] .