Cron job output result
I had recently a system CRASH and was forced to reinstall KDE Neon Plasma from scratch. It took a couple of days to restore and reinstall some apps and it seems to all work OK now.
I am using the built in Task scheduler to run a Backup cron script to an external hard disk. This also works OK, but the script output of the end, DOES no longer show up, it creates an EMPTY log file on the desktop, below is the command line that used to work, but now doesn't. usr/bin/rsync -a /home/alexe/afolders/ /media/alexe/Elements/$ldow/ >/var/tmp/anajob.out Nor does this command: /usr/bin/rsync -a /home/alexe/Desktop/ /media/alexe/Elements/$ldow/ > /home/alexe/Desktop/dback.txt Any help will be good Many thanks Alex |
Is it possible you are remembering the command incorrectly?
'rsync -a' does not produce an output to screen, but 'rsync -av' does. If $ldow has an assigned value before the command is run rsync would create or use the directory. If $ldow has no value then the copy would be created in /media/alexe/Elements/ . There would be no entry made in the logfile without the -v option since rsync runs silently unless there is an error (which would not appear in the log) or the -v (verbose) option is used. |
Quote:
Here is the complete script, yes that -av works, BUT it listed in the output 2036 lines of all the files that it copied. I used to get a single line of the action with date and time stamp.... Quote:
Many thanks |
Take out the redirect to the log file and run it a few times. You will see after the first run, all subsequent runs will have little or no output because rsync has already copied the data. Also you might throw a --delete to get rid of removed files and a real representation.
|
Quote:
I am confused Cheers |
I think that suggestion to remove the redirect was so you can see on screen exactly what should be being written to the log file.
I used rsync to copy a directory tree and even with a large number of files the 'rsync -a' gave me nothing in the logfile. With -av it showed exactly what was copied. After doing a backup that way IF you were writing to the same directory the -av would only display changes. Since you are creating a new directory each time it will always show the full list of files copied. Copying all the files each time seems a major waste of time and resources when rsync takes care of only doing it as incremental when doing the backup into a previously used copy. For example, I have about 5 TB of data and if I did a full backup each time it would take hours and a major amount of disk space for each backup. Since I do it as incremental it only takes a few minutes and the backup remains at the same size as the original, forever. |
So I don't see a creation every run, sat dir would have sat, fri would have fri etc. But it would accumulate with deleted files and not a representation of a restore, that is why --delete. Yes, you would have everything, but if you stored a iso and then removed it, the image
would be your backup until you cleared it. So using rsync in this manner at least not copy things already there and you could run it multi times a day and it would only copy updates. That is why I said don't use the redirect, the first time it copies everything and the next time nothing (or at least only the changes). |
Quote:
I used to have a log file that showed ONE single line per each dayly backup - that would be fine for me. So, How can I get back that this setup? Thanks again |
Quote:
Cheers Alex |
-v lists all the copied files.
--stats gives a summary line. Code:
/usr/bin/rsync -a --stats ... |
Quote:
I made the suggested change, what the log file has now is the following: Code:
Number of files: 19,848 (reg: 16,178, dir: 3,670) Thank you |
Hmm, you can get this from the file's meta data:
ls -l filename or stat -c %y filename Perhaps you want another command to create the file? Code:
/usr/bin/rsync -a /home/alexe/Desktop/ /media/alexe/Elements/$ldow/; date > /home/alexe/Desktop/dback.txt |
I don't know of an rsync option but as posted just write the timestamp of the date command to your file.
|
Quote:
Quote:
Many thanks |
Check the rsync exit code. 0 means success.
|
All times are GMT -5. The time now is 11:38 PM. |