Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for No Output for Python Script Executed via Cron Job

Current License: CC BY-SA 3.0

18 events
when toggle format what by license comment
Jul 26, 2015 at 3:03 vote accept AdjunctProfessorFalcon
Jul 26, 2015 at 3:02 answer added AdjunctProfessorFalcon timeline score: 0
Jul 24, 2015 at 1:34 comment added Etan Reisner You seemed to want the output in an email in the first place. If that's the case then yes, drop the redirection to the file entirely and instead just pipe it to mailx (probably with standard error too 2>&1). Otherwise, if you do want a log file, and that is a per-user crontab, then use a directory that your user can create files in (i.e. not /var/log`).
Jul 24, 2015 at 1:30 comment added AdjunctProfessorFalcon Are you saying I could just skip sending the output to /var/log or any other log directory and instead just put the output in an email?
Jul 24, 2015 at 1:27 comment added Etan Reisner I doubt that would help. That env command pattern is one of the debugging steps for non-working cron commands (in the crontab info wiki) though. So your command itself works in the cron environment but something else is going on that is keeping it from working correctly in cron itself. Wait... is that per-user crontab trying to write to /var/log? That's not going to work. Try some other directory and/or stop that and just pipe to mailx.
Jul 24, 2015 at 1:02 comment added AdjunctProfessorFalcon Yes it does! Does that mean I can take this line and insert it into Crontab? env -i sh -xc '/home/local/MYCOMPANY/purrone/MyPythonScripts_Dev1/ParserScript_CampusInsiders.‌​py > /var/log/crondate +\%Y-\%m-\%d-\%H:\%M:\%S-cron.log 2>&1'
Jul 23, 2015 at 20:04 comment added Etan Reisner And does it have the contents you expect when you run it like that?
Jul 23, 2015 at 19:34 comment added AdjunctProfessorFalcon Yes! Now I can see: cron2015-07-23-15:33:35-cron.log
Jul 23, 2015 at 19:32 comment added AdjunctProfessorFalcon Yes, I'm looking in /var/log directly
Jul 23, 2015 at 18:25 comment added Etan Reisner Does using $(...) instead of backticks help any? Can you run env -i sh -xc '/home/local/MYCOMPANY/purrone/MyPythonScripts_Dev1/ParserScript_CampusInsiders.py > /var/log/cron`date +\%Y-\%m-\%d-\%H:\%M:\%S`-cron.log 2>&1' correctly? Does it create the log file?
Jul 23, 2015 at 18:22 comment added Etan Reisner You are looking in /var/log/ directly and not /var/log/cron/ right? If you don't see the files then that shell command isn't being run at all. (And I wouldn't expect you to get any mail either.)
Jul 23, 2015 at 17:55 comment added AdjunctProfessorFalcon I don't see anything that looks like cronxxxxx-cron.log. All I'm seeing that directory that looks related to cron jobs is: chrony, cron, cron-20150719. Nothing related to my script in those files.
Jul 23, 2015 at 17:50 comment added Etan Reisner Does the correct /var/log/cronXXXXX-cron.log file get created at least? Even if it then empty?
Jul 23, 2015 at 17:27 history edited AdjunctProfessorFalcon CC BY-SA 3.0
added 540 characters in body
Jul 23, 2015 at 17:26 comment added AdjunctProfessorFalcon Actually, I'm seeing that there's no output from the script in the log file at /var/log/cron when I opened cron with cat cron there's just the actual cron job. Inserting what I'm seeing in log to my post above...
Jul 23, 2015 at 17:18 comment added Etan Reisner Is that cron log file working? You aren't sending any output to mailx where is it supposed to be getting the content of your email from?
Jul 23, 2015 at 17:17 answer added Micah Elliott timeline score: 1
Jul 23, 2015 at 17:11 history asked AdjunctProfessorFalcon CC BY-SA 3.0
toggle format

AltStyle によって変換されたページ (->オリジナル) /