ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Running Ubuntu 8.10 and have created the following user cronjob that backs up all my data in my home directory:
Code:
#!/bin/bash
# backup data on a daily basis via rsync and a cron job
echo backup started `date` >>/home/cmmiller/backup/backuplog
rsync -avh /home/cmmiller/ /media/Linux_ext3/
echo backup complete `date` >>/home/cmmiller/backup/backuplog
echo du -csh /media/Linux_ext3 | df -h /media/Linux_ext3 >>/home/cmmiller/backup/backuplog
echo
This past weekend I cleaned up my home directory and then deleted all of the files on the external hard drive so it would display the data as it now appears in my home drive.
For some reason after doing this, the cron job now hangs. I can look at top and see various processes running. I kill the processes and the cron job completes.
I ran the cron job for the hell of it from the command line and didn't have the same issue, so I'm not sure what is going on...I am writing to a log to check the progress the next day, however it isn't telling if there is an issue or not.
well you're piping the string "du -csh /media/Linux_ext3" (not the results of the command, which doesn't really matter because either would be wrong) into 'df', which is meaningless. the result of that is what is getting written to your log.
yes, clean up your script and see if it works better.
here's a helpful trick. you can put your code in a block and redirect the output from the whole block to your log file in one step. that way you don't have to worry about getting all of the redirects in the right place. within the block you can just write script as normal.
Code:
#!/bin/bash
# backup data on a daily basis via rsync and a cron job
{
echo backup started `date`
rsync -avh /home/cmmiller/ /media/Linux_ext3/
echo backup complete `date`
du -csh /media/Linux_ext3
df -h /media/Linux_ext3
echo
} >>/home/cmmiller/backup/backuplog
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.