Nice-looking cron replacement for django:
https://pypi.python.org/pypi/django-periodically/0.3.0
Recursive algorithms can be slow because they end up solving the same little problems over and over again. To speed them up, you can use a technique called "memoization." Memoization allows algorithms go much more quickly by remembering solutions to problems they have already solved. I’m the recursive algorithm. This blog is my memoization.
Showing posts with label cron. Show all posts
Showing posts with label cron. Show all posts
Monday, December 8, 2014
Nice looking cron replacement for django
Thursday, November 20, 2014
cron debugging: cat /var/log/syslog
So I wanted to test a cron job and make sure that it was running. I decided to make it something obvious, so I made my command
/usr/bin/firefox www.google.com
and told it to run every minute. And I got nothing. After restarting cron and making sure that the last line in crontab had a newline and everything I could think of, I finally looked at the syslog and learned that it was running. It just didn't output anywhere I could see it.
So here's another case where it's worth looking at syslog:
cat /var/log/syslog
The cron output isn't visible unless you direct it to a file that you choose and look at that file.
/usr/bin/firefox www.google.com
and told it to run every minute. And I got nothing. After restarting cron and making sure that the last line in crontab had a newline and everything I could think of, I finally looked at the syslog and learned that it was running. It just didn't output anywhere I could see it.
So here's another case where it's worth looking at syslog:
cat /var/log/syslog
The cron output isn't visible unless you direct it to a file that you choose and look at that file.
adding commands to manage.py (if you don't like the shell < script.py trick)
Say you want to do something periodically that will affect your django environment (like check email). You can schedule a task to do that using cron. But that task needs to be run within your django environment.
One way to do that is to use
python manage.py shell < script.py
(or, if you have your permissions altered via chmod +x,
./manage.py shell < script.py
)
It works.
If you want to get fancier, you can make a custom command for manage.py:
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/
One way to do that is to use
python manage.py shell < script.py
(or, if you have your permissions altered via chmod +x,
./manage.py shell < script.py
)
It works.
If you want to get fancier, you can make a custom command for manage.py:
https://docs.djangoproject.com/en/dev/howto/custom-management-commands/
Subscribe to:
Posts (Atom)