Currently I have a python script that is running in a cronjob. I am redirecting any standard error from the script to append to a log file. I am trying to add a timestamp to the beginning of each write and cannot figure out how to do this in my crontabjob one-liner.
Cronjob:
*/5 * * * * /usr/bin/python .../jira_ticket.py 2>> .../error.log
Thanks in advance for any assistance.
UPDATE: SOLVED
I have solved my issue using the logging module in python. This module needs to be installed via pip.
` import logging
logging.basicConfig(filename='.../error.log', filemode='a', format='\n\n\n%(asctime)s - %(levelname)s - %(message)s') `
So now my errors in the log appear as:
2018-10-30 16:55:03,259 - ERROR - Exception Occured
Followed by the error.