What time zone is a cron job using?
Cron job uses the server's define timezone (UTC by default) which you can check by typing the date
command in terminal.
All countries timezones are defined in /usr/share/zoneinfo
directory:
cd /usr/share/zoneinfo/
When you cd into this directory you will see the name of different countries and their timezone.
Command to change server timezone.
sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
If you live in America > LA you can change your time-zone using above command. Change the country and state according to your requirement.
Command to check the date and time:
date
Set time and date from the command line:
date -s "19 APR 2012 11:14:00"
If you have may users, with many crontabs and they have different time zone requirements, you cannot just change system timezone.
But you still can set a specific time zone to be used just for the cron jobs in a specific crontab setting the variable CRON_TZ at the beginning of the crontab.
E.g.
#@IgnoreInspection BashAddShebang
SHELL=/usr/bin/bash
CRON_TZ=UTC
PROJECT_DIR=/home/MY_USER/MY_PROJECT
40 06 * * 1-5 $PROJECT_DIR/prod/ingest.sh >> $PROJECT_DIR/logs/ingest_cron.out 2>> $PROJECT_DIR/logs/ingest_cron.err