top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Add time to log file for cron job

+1 vote

I'm trying to figure out a way to insert a timestamp into a log file I'm creating for a cron job:

/usr/bin/rsync -v --min-size=1 -rlpgo -O --inplace /home/myuser/Get*
root@xx.x.xx.xx:/mnt/yyy/zzz/compass 2>&1 >& /tmp/rsync_user.log

I've googled this but all I could find are tips on how to add the time and date to the name of the log file itself, not to the contents of the log.

Any tips or pointers would be great.

posted May 24, 2014 by Abhay Kulkarni

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
This is what worked, thanks for your help

$/usr/bin/rsync -v --min-size=1 -rlpgo -O --inplace /home/compassfeeduser/Get* root@xx.xx.xx:/mnt/yyy/zzz/compass | ts  2>&1 >& debug.txt

$ cat debug.txt
May 23 23:44:49 sent 67 bytes received 12 bytes 158.00 bytes/sec

1 Answer

+1 vote

Why not make your rsync command into the second line of a script, and make the first line of the script write the time to the log.

answer May 24, 2014 by Anderson
Similar Questions
+1 vote

I'm interested in a replacement for cron which would allow me to run various cron jobs on demand, and mark them as having been run, so they won't be run again from the schedule.

I noticed whenjobs, which looks like it may do the job. The documentation for whenjobs says that it is obsolete and has been replaced by goaljobs.

Has anyone tried out whenjobs or goaljobs.

+2 votes

Currently svn log will display file changes and svn:externals property changes, but will not display changes made to the file pointed at by the external. For example, if a user commits a change to a file external, svn log will show that the properties reflects a new revision of the file is now being referenced, but will not see commit made to the file, even if it was done from the current WC.

It would be a very useful feature to have svn log include the log of the file external(s) as if it were a formal vile within the WC (even if it required a switch --include-externals) to enable.

+1 vote

Do you need cron installed for the files in /etc/cron.daily/ to execute?

Did a Centos 6.x minimal openvz install and noticed cron is not installed by default and after installing mlocate cant help but wander if it will be updated without it.