You are not logged in.
In my systemd setup I don't have syslog-ng installed nor sendmail, so I'm wondering where the output generated by cron jobs is stored. I can't find it in systed's journal using journalctl, nor in /var/log. Is it lost because I need either syslog or sendmail to be present?
Thanks
Offline
Mine is in the journal. For example, the command "journalctl |grep CRON" outputs everything for both root and normal users.
All men have stood for freedom...
For freedom is the man that will turn the world upside down.
Gerrard Winstanley.
Offline
I can't see mine. I want to check if my anacron script to weekly execute SSD trim:
$ cat /etc/cron.weekly/fstrim
#!/bin/bash
fstrim -v /
ll /etc/cron.weekly/fstrim
-rwxr--r-- 1 root root 24 25 nov 15.36 /etc/cron.weekly/fstrim
has actually been executed. By doing "journalctl |grep CRON" I see nothing related to it, while grep'ing anacron I get:
$ sudo journalctl | grep anacron
7714:Nov 25 15:25:43 elric anacron[1540]: Anacron started on 2012-11-25
7715:Nov 25 15:25:43 elric anacron[1540]: Can't open timestamp file for job cron.daily: Permesso negato
7716:Nov 25 15:25:43 elric anacron[1540]: Aborted
7717:Nov 25 15:26:15 elric sudo[1566]: mori : TTY=pts/2 ; PWD=/home/mori/analysis/CALET ; USER=root ; COMMAND=/usr/bin/systemctl start anacron
7951:Nov 25 16:01:01 elric anacron[2015]: Anacron started on 2012-11-25
7953:Nov 25 16:01:01 elric anacron[2015]: Will run job `cron.daily' in 6 min.
7954:Nov 25 16:01:01 elric anacron[2015]: Will run job `cron.weekly' in 26 min.
7955:Nov 25 16:01:01 elric anacron[2015]: Will run job `cron.monthly' in 46 min.
7956:Nov 25 16:01:01 elric anacron[2015]: Jobs will be executed sequentially
7958:Nov 25 16:07:01 elric anacron[2015]: Job `cron.daily' started
7959:Nov 25 16:08:22 elric anacron[2015]: Job `cron.daily' terminated
15606:Nov 26 14:01:01 elric anacron[4455]: Anacron started on 2012-11-26
15608:Nov 26 14:01:01 elric anacron[4455]: Will run job `cron.daily' in 6 min.
15609:Nov 26 14:01:01 elric anacron[4455]: Will run job `cron.weekly' in 26 min.
15610:Nov 26 14:01:01 elric anacron[4455]: Will run job `cron.monthly' in 46 min.
15611:Nov 26 14:01:01 elric anacron[4455]: Jobs will be executed sequentially
15855:Nov 26 14:07:01 elric anacron[4455]: Job `cron.daily' started
15856:Nov 26 14:07:08 elric anacron[4455]: Job `cron.daily' terminated
15927:Nov 26 14:27:01 elric anacron[4455]: Job `cron.weekly' started
15935:Nov 26 14:29:08 elric anacron[4455]: Job `cron.weekly' terminated (mailing output)
15936:Nov 26 14:29:08 elric anacron[4455]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
15969:Nov 26 14:47:01 elric anacron[4455]: Job `cron.monthly' started
15970:Nov 26 14:47:01 elric anacron[4455]: Job `cron.monthly' terminated
15971:Nov 26 14:47:01 elric anacron[4455]: Normal exit (3 jobs run)
I can see that on Nov 26 14:29:08 the weekly jobs were executed but sending of the output through sendmail failed. So I guess (hope?) that logs are somewhere else.
Alternately, can I force the execution of weekly jobs to check if they produce output on syslog (without waiting one week)?
Offline
can I force the execution of weekly jobs to check if they produce output on syslog (without waiting one week)?
Sure.
Offline
Anacron runs its stuff as daily weekly and monthly. So it is actually just running a directory of scripts at each of those intervals. That is why it is not logging stuff from anacron in the journal, except to tell you that it has started or finished. If you want it to tell you what the specific job has completed, have your fstrim script redirect output to logger.
Edit: Here is an example of trimming the root fs, and having its output appear in the journal (I have not looked at this script in a while, so I am not sure why there is both a redirect and a pipe... but it seems to work, so I am not going to mess with it):
/sbin/fstrim -v / 2>&1 | /usr/bin/logger -i
Last edited by WonderWoofy (2012-11-29 00:57:26)
Offline
The redirect sends errors to standard output. The pipe sends standard output to logger. With just the pipe, you'd not catch the error stream.
Last edited by cfr (2012-11-29 02:17:40)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
Thanks guys, I'll add manual output redirection to journal to my script!
Offline