Cron does not output results when run on schedule despite settings.

learnsomemore

Dabbler
Joined
Aug 16, 2018
Messages
11
I have a cron running in Tasks > Cron Jobs. If from the GUI, i click the job and click "run now", it runs perfectly and outputs results to terminal and the system also sends text to another syslog server. "Redirect Stdout" and "Redirect Stderr" is not checked because they both say that checking them "disables output".

The problem is, when i'm not in the GUI and the system is running on the schedule, the cron job runs on-time (verified by watching /var/log/cron), but does not produce any output, even though the first thing my script does is echo text "cron job started".

I'm not sure why the output is different when run:
  • automatically via GUI scheduler (no output),
  • command line added crontab (no output),
  • command line execute script (output),
  • or via the GUI "run now" option (output) option.

Is this a bug?

As a workaround, i changed script to echo to logger. Now output goes to messages log and the configured remote syslog server. I also noticed that if I manually add the script as a cron job with crontab -e under the user, I have the same problem. Maybe it's a FreeBSD thing as I don't have this issue in Ubuntu.

System: FreeNas-11.1-U6
 
Last edited:

RocketLR

Cadet
Joined
Dec 21, 2020
Messages
1
Were you able to figure this out?

I haven't run into this problem but I did find it very annoying that if I wanted to use the crontab jobs on freenas to backup some of my switches, I needed to uncheck stdout redirect and receive annoying emails of each job, every time. Otherwise the backup.cfg file was created but contained nothing.

To be able to write to files and not get spammed with emails each time a cron job is executed, I did this:
ssh user@crappy-cisco-sw show run | tee /path_to_my_pool/backup/devices/FP-SW-01A_$(date +"%y%m%d").cfg

check the box "hide standard output" and pipe into tee followed by path to the file.

Im writing this here because I've been searching for how to get around this annoying feature and found nothing.
There are probably better ways of creating backup jobs, but im stretched thin here and severely limited on what im allowed to use.
 
Top