Configuring the timezone settings in Linux and setting a cron job to use the new timezone permanently

|
| By Navneet Kashyap

Step 1: To check the current timezone of the Linux server
timedatectl

Step 2: To list all available time zones in the Linux server
timedatectl list-timezones

Step 3: To set the desired timezone on the Linux server
timedatectl set-timezone America/Los_Angeles

Step 4: By default, cronjob uses UTC timezone even if you set the timezone of your choice in the Linux server. So, in order to use the desired timezone in cron also you can also use the below method to set it.

crontab -e

Put the below parameters in the crontab file, for example, I have used PST timezone (America/Los_Angeles)

CRON_TZ=America/Los_Angeles

Finally, restart the Cron service

systemctl restart crond.service

Leave a Reply

Your email address will not be published. Required fields are marked *