Comments (6)
Maybe we're running into a problem because the current working dir differs when started via cron. Please change the FileHandler's filename to be absolute. Does this help?
Another try: switch to ConsoleHandler and pipe result into a file:
('0 0 1 * *', 'myapp.cron.my_scheduled_job', '>> /tmp/scheduled_job.log'),
Does this work?
from django-crontab.
Can you provide your Django & Python version with your (simplified) settings for CRONJOBS, LOGGING?
Additionally what happens when you run
$ python manage.py crontab show
and find the logging job's hashed id and run
$ python manage.py crontab run <id>
Does the logging work in this case?
from django-crontab.
Shouldn't be there a logger for app.tasks
as well? Depending on how log propagation is configured, that may a reason. But sure, if it's working from the django shell...I try to check that soon.
from django-crontab.
Django: 1.9.4, Py: 2.7.11
In settings.py:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'mysite.log',
'formatter': 'verbose'
},
'scraper_file' : {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': 'scraping.log',
'formatter': 'verbose'
}
},
'loggers': {
'django': {
'handlers':['file'],
'propagate': True,
'level':'DEBUG',
},
'scraper': {
'handlers': ['scraper_file'],
'level':'DEBUG',
'propagate': True,
},
'django_crontab': {
'handlers': ['scraper_file'],
'level':'DEBUG',
'propagate': True,
},
'django_crontab.crontab': {
'handlers': ['scraper_file'],
'level':'DEBUG',
'propagate': True,
},
'crontab': {
'handlers': ['scraper_file'],
'level':'DEBUG',
'propagate': True,
},
'scraper.django_crontab.crontab': {
'handlers': ['scraper_file'],
'level':'DEBUG',
'propagate': True,
},
'scraper.tasks': {
'handlers': ['scraper_file'],
'level':'DEBUG',
'propagate': True,
},
}
}
When runnig python manage.py crontab show
it returns:
Currently active jobs in crontab: d2cbb85ad5f39a8d633df70b63312728 -> ('0/8 * * * *', 'scraper.tasks.my_scheduled_job')
and running python manage.py crontab run d2cbb85ad5f39a8d633df70b63312728
both correctly runs the function, and logs correctly. However, when cron runs the function, I can see the results showing up in the database, but nothing is being logged.
from django-crontab.
I came into the same problem. After changing the FileHandler's filename to be absolute path, it all settled. Probably the working dir issue. Thanks.
from django-crontab.
Thanks for sharing @Ryan-ZJU. I added a faq entry about this. Hopefully this helps the next one :)
from django-crontab.
Related Issues (20)
- python manage.py crontab add is not working on heroku server HOT 1
- ModuleNotFoundError: No module named 'fcntl'(windows ) HOT 1
- Cron job with hidden file
- How to run crontab job as user instead of root
- Django Crontab not working on a specific time HOT 6
- macOS 10.15.6 Failed to import the site module HOT 3
- Crontab does not work when running server HOT 3
- Django cronjob error while using database HOT 4
- Does it work in Django==3.1.2 ? HOT 3
- ImportError: Couldn't import Django HOT 1
- List of all optional argumentsfor django-crontab
- How to call a command with no-value arguments
- Why we can't add individual job and can't remove individual job to crontab HOT 1
- Not call cronjob HOT 6
- How do I run a job without adding it to cron HOT 2
- Consider moving the project to Jazzband? HOT 1
- Django Crontab on docker-image not reading env-variable from K8S deployment config HOT 1
- python3 manage.py crontab add not executing HOT 1
- Django Crontab Job Not Executing Within Docker Container HOT 9
- Can I set a timeout for a job?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-crontab.