Cron job logs both by email and file

Hi there!

Maybe someone could give me a hand here, please?

I have some tasks which I have configured in Manjaro through cronie. I am sending the logs perfectly by mail (I put that MAILTO line into my cron file).

But, is it possible to have both options, i.e., logs being sent by email and also recorded in a file?

Thanks in advance!

On a per-job basis that’s easily done via “tee”. I.e., if your stdout is already getting through to email correctly just have the command be

x x x x x /usr/local/bin/foo | tee -a /tmp/foo.log

or some such.

1 Like

All the output is also saved in the journal. The journal is not a textfile, but you can access the journal with the journalctl command.
If you really want, you could even install a syslog program to pipe your journal messages to a real text file. This would not my first choice, but if you need it.

Hi again,

Thank you very much guys! :slight_smile: