Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple enhancement: run cronjobs from management.py #4

Open
GoogleCodeExporter opened this issue Dec 16, 2015 · 8 comments
Open

simple enhancement: run cronjobs from management.py #4

GoogleCodeExporter opened this issue Dec 16, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

Even on systems where cron/shell access is available, it is preferable to
only have one actual cronjob and let django-cron do the rest, because that
does not only make deployment easier, but also leads to cleaner application
code.

Fortunately, it is very simple to enhance django-cron this way - the
attached patch enhances manage.py with cron-running capabilities.


Original issue reported on code.google.com by chris.vigelius on 16 Jun 2008 at 10:11

Attachments:

@GoogleCodeExporter
Copy link
Author

I think with all my changes, your patch may not work anymore. The problem with 
this
approach though (if I understand correctly) is you need an actual cron job to 
kick it
off.

The goal of this project (as stated on the project home page) is to enable 
cron-like
functions without shell access, (or whatever other reason) for people on shared
hosting etc.

Original comment by [email protected] on 18 Apr 2009 at 1:17

@GoogleCodeExporter
Copy link
Author

Is this also intended to allow you to test whether the cron job code works from 
a
command line?  In that case I can see the usefulness when setting up jobs that 
need
to be tested.

Original comment by [email protected] on 15 Jun 2009 at 7:27

@GoogleCodeExporter
Copy link
Author

I agree with the statement in the original issue: "it is preferable to only 
have one
actual cronjob and let django-cron do the rest". Even when cron is available on 
the
system, it would be useful to have a simple way to register jobs with a central 
cron
manager.

Original comment by [email protected] on 20 Jul 2009 at 6:05

@GoogleCodeExporter
Copy link
Author

Attached is an updated patch. Some changes were needed in __init__.py and 
base.py, as
invoking Timer() makes the script run forever from the command line.

I don't think this code is quite acceptable yet (it doesn't return any useful
information upon running, for example) but it seems a useful start.

(As I noted above, I think this is useful functionality. A cron-enabled hosting
environment would simply use a cron script to run "manage.py cronjobs", and the
urls.py configuration is not needed.)

Original comment by [email protected] on 20 Jul 2009 at 7:21

Attachments:

@GoogleCodeExporter
Copy link
Author

An update: my changes are not compatible with lines 39-47 of base.py, as it'll 
lead
to all jobs being deleted on every cron run. I realize that block makes sense 
for the
thread/timer approach, but it doesn't help in this case. I just deleted those 
lines
from my code, but I'll consider a cleaner solution.

Original comment by [email protected] on 21 Jul 2009 at 2:14

@GoogleCodeExporter
Copy link
Author

I think this patch is an excellent idea. I'm on the verge of writing my own
cron-manager to do exactly that.

Original comment by andybak on 23 Oct 2009 at 2:01

@GoogleCodeExporter
Copy link
Author

I applied the patch manually to r26 and it works perfectly. (by manually I mean 
by
reading the patch and making the individual changes).

Original comment by andybak on 26 Oct 2009 at 4:45

@GoogleCodeExporter
Copy link
Author

A further comment is that I couldn't get django-cron working until I used the 
patch.
I didn't try too hard as I preferred to use the manage.py method (shared 
hosting so
memory is at a premium and I thought the original method of execution might 
leave an
instance of Django hanging around)

Original comment by andybak on 26 Oct 2009 at 4:48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant