I
I
Ivan Semenov2019-05-30 09:03:44
FreeBSD
Ivan Semenov, 2019-05-30 09:03:44

How to output the result of a job in cron to a file with a runtime stamp?

Good afternoon!
There is a job in cron that executes the command to restart the named service every day at 5 am (why it is not important), and actually output the result of this command to a file like /var/log/named_restart.log.
But if you open this file and look at the entries, they will all be the same:

Stopping named.
Waiting for PIDS: 86988.
Starting named.
Stopping named.
Waiting for PIDS: 98754.
Starting named.

And I would like to put a timestamp when this task was completed.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitsliputsli, 2019-05-30
@Vitsliputsli

So add to Cron, before the restart command, a time entry. The log, as I understand it, is written directly from cron?

P
Pavel Mezhuev, 2019-05-30
@mezhuev

Use syslog.
/etc/syslog.d/named_restart.conf:
local0.* /var/log/named_restart.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question