I run a job at specific date[Client time not local time] to send email to my clients.
I use cpanel cron job
i tried to use cron job with time zone
but it still sending in my local time zone
32 16 08 05 * /usr/bin/curl CRON_TZ=Africa/Algiers https://www.example.com/SendCron.php?CronID=382 #CronID382END # z93v66
what wrong i did using Cron_TZ ??
Best Answer
Your
CRON_TZ=
is in a wrong place in yourcrontab
file, as an option attribute for/usr/bin/curl
.You should instead have it as an environment variable set before the cron entries:
If you need to have time zone set for a single cron entry on the same single line, it is not possible with the
CRON_TZ
environment variable, but you need to invoke externalenv
(run a program in a modified environment) to change theTZ
:Notice that both changes the time zone for the command, not for cron daemon. The cron daemon just checks whether the fields matches current time or not, regardless of the
CRON_TZ
variable. The manual page for systemd-croncrontab
explains this limitation:If you need to run the schedules based on timezone, you must change the server timezone, e.g.: