Friday, November 2, 2018

Is it possible to make an individual daily cron run with UTC time while keeping the system localtime?

I have a cron script under /etc/cron.d as so:




SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin




0 0 * * * root /usr/local/sbin/app_logrotate >> /var/log/app-newday.log




This works but it executes always at 00:00 local time. The app in question uses UTC time ( I cannot change this). In my time zone this is a few hours behind resulting in the date tag on the daily logfile this application creates never being a new day.
I can't change the system localtime to UTC as other applications depend on localtime.
I was wondering if it is possible to execute this cron only at 00:00 UTC while keeping my system localtime.
I have tried adding TZ=UTC to the cron script which did not work.
Does anyone know how this can be done?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...