Skip to main content

Time zone cron jobs execute within, if different from server time zone

Comments

5 comments

  • cPRex Jurassic Moderator
    Hey there! If the machine's timezone has been properly set, I would recommend restarting the crond service in general to see if that makes it pick up the correct time from the machine itself. I'm not seeing anything obviously wrong with the details you provided in your first post, so that would be the first thing I'd try.
    0
  • bblsystems
    The machine time zone is set via the hosting company (and is CST) and we cannot change it. How can we make a PHP CRON script execute in a different time zone from the server time zone, within the cPanel jailshell framework?
    Hey there! If the machine's timezone has been properly set, I would recommend restarting the crond service in general to see if that makes it pick up the correct time from the machine itself. I'm not seeing anything obviously wrong with the details you provided in your first post, so that would be the first thing I'd try.

    0
  • cPRex Jurassic Moderator
    Instead of "TZ=" can you try using this in the file CRON_TZ=America/New_York
    to see if that changes the behavior?
    0
  • bblsystems
    The jailshell seems to affect editing. We would use crontab -e to edit the cron script and save our changes. We could check the cron table afterwards and our changes would be there. After a certain amount of time, we'd edit crontab -e and our changes would be gone. We don't know for sure, but it seems like some feature of jailshell was re-creating our crontab script and deleting our changes. Ultimately, since these were PHP scripts, we added a config.php file to the folder that contained the scripts. The config.php contained the lines: define('TIMEZONE', 'America/New_York'); date_default_timezone_set(TIMEZONE); We don't know if the CRON_TZ would have worked or not. Setting the timezone via config file caused the scripts in the same folder to use the correct time zone.
    0
  • cPRex Jurassic Moderator
    Did that additional config file allow things to run how you expect?
    0

Please sign in to leave a comment.