1

I use cron to control a python script

*/10 * * * * /usr/bin/python3 /home/user/FillDatabase.py

and its works well so fare. The python script itself produce logging in case of error.

import logging
...
logging.basicConfig(level=logging.INFO, format="[%(module)s] %(message)s")
...
try:
    ...

except Exception as e:
    logging.info('error while writing: {0} \n'.format(e))

I want so see these python logging messages in the syslog.

i tried

*/10 * * * * /usr/bin/python3 /home/user/FillDatabase.py 2>&1
2
  • 2
    Does this answer your question? How to configure logging to syslog in Python? Commented Nov 5, 2022 at 22:01
  • I think no. the logging itself (from the python script to syslog) works, but not "behind" cron. Commented Nov 5, 2022 at 23:00

1 Answer 1

0

found:

Wirte to cron with

sudo crontab -u root -e

give cron the permission to write into syslog

*/10 * * * * /usr/bin/python3 /home/user/FillDatabase.py >> /var/log/syslog 2>&1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.