01 / 08
The weakness of not knowing afterwards
Last lesson you built something you could take your hands off.
0 5 * * * /home/learner/checkup.shBut what happened at five in the morning, you did not see.
did it go well?did it fail?did it run at all?None of it is known. All cron leaves is that it ran it.
Last lesson you got round it by writing this.
... >> /home/learner/result.log 2>&1That does keep a record. But three things are awkward.
1. files multiply (one per job)2. no time goes in (you do not know when)3. you cannot read it beside the other recordsThe third matters. Inside the machine, all sorts of things are writing records.
syslogd that it startedcrond that it ran a jobsu who became the administratorAnd all of it is in one place, in order of time.
~ $ tail -3 /var/log/messagesAug 22 07:18 ... syslogd started: BusyBox v1.37.0Aug 22 07:19 ... crond: USER learner pid 88 cmd ...Aug 22 07:19 ... su: + ttyS0 root:learnerYour records can be mixed in here too. The tool for it is logger.
What is good about mixing them in? This.
07:19:00 crond started the job07:19:00 checkup five files07:19:01 checkup odd! it was emptyIt reads as a story. Scattered across separate files, you would have to line up the times by hand.