I have an hourly crontab job
@hourly rsync -avc --delete /DirA/ /DirB/ > /home/job.txt
However when I check the logbook I see no timestamps. How can I get timestamps in the log so that I can be able to see when error occur?
I have an hourly crontab job
@hourly rsync -avc --delete /DirA/ /DirB/ > /home/job.txt
However when I check the logbook I see no timestamps. How can I get timestamps in the log so that I can be able to see when error occur?
Try this:
Note that I used
&> /home/job.txt
which redirects both the standard output and the standard error to the log file. That way you will also see any errors produced. Then, I use thedate
command to generate a timestamp before running thersync
. Placing the commands in parentheses makes the two run in the same subshell and allows the redirection of both commands' output at once.