WebFaction
Community site: login faq

I have noticed that my cron job will not run if a specify an hour value other than *. I have also noticed that if my cron job runs a python (via django) script that returns datetime.now() the hour is one hour behind. In other words, it is not adjusted to daylight savings time. I am not sure if these two things are related so I mention them both.

Here are my cron jobs (from crontab -l). It is the final (django) command that is in question.:

0,20,40 * * * * ~/webapps/django/apache2/bin/start
PYTHONPATH=/home/username/lib/python2.7:/home/username/webapps/br_django155_py27/lib/python2.7
DJANGO_SETTINGS_MODULE=appname.settings
MAILTO=my_email@host.com
MAILFROM=admin@username.webfactional.com
* * 11 15 14 * * /usr/local/bin/python2.7 /home/username/webapps/br_django155_py27/appname/manage.py cron_test 2>&1

I have tried various minute and day field values, including * and all work as long as the hour field is set to *. I have also tried an hour field that is one hour behind to compensate for the daylight savings time hour difference.

Firstly, why can I not restrict the hour field? Secondly, why is the hour not adjusted for daylight savings time? By the way, I am using django version 1.5.5 with the following settings:

TIME_ZONE = 'America/Chicago'

but I do not specify: USE_TZ = True. I leave this setting out. I have yet to test if this makes a difference.

asked 14 Dec '13, 14:45

Roland
21510
accept rate: 0%

edited 14 Dec '13, 14:48

The django script output the following at 15:11 (3:11pm) EST:

Django Script says Hello at 2013-12-14 14:11:03.499409 via cron.

Note that the hour field is one hour behind.

(14 Dec '13, 14:55) Roland

cron runs based on the server's time, which is set to UTC. If you need it to run in a specific time zone you will need to run it at the equivalent time in UTC for it to be correct.

permanent link

answered 14 Dec '13, 18:23

waynek
4254
accept rate: 27%

Thank-you that was it. So 8pm EST = UTC 1am; i.e. EST = UTC - 5hrs. (and one day).

(14 Dec '13, 19:06) Roland
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×81
×1
×1
×1

question asked: 14 Dec '13, 14:45

question was seen: 3,421 times

last updated: 14 Dec '13, 19:06

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM