|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
Cron and email
I have the following line in root's crontab:
Code:
00 06 * * * /root.backup.sh -m Code:
#!/bin/sh mount /dev/sd1a /mnt/ /usr/local/bin/rsync -avh --exclude-from=/home/stan/rsync.exclude /home/stan /mnt/ /usr/local/bin/rsync -avh /etc /mnt/ /usr/local/bin/rsync -avh /var //mnt/ cd /home/stan/ umount /mnt/ sleep 5 shutdown -p now If I remove the last 2 lines, the backup occurs and I get email confirmation. What I'd like to know is why this occurs and how can I run the script as is and receive confirmation? Any help would be appreciated. Thanks |
|
|||
Cron and email
Your theory appears to be correct. I tried your suggestion and things are working fine now.
Thanks for your assistance. |
|
||||
I'm glad to hear it worked! I thought of one tweak to do it a little more cleanly. Instead of using a second script as I suggested, you could try ending the first (and only) script with this:
( sleep 5 ; shutdown -p now ) & That keeps everything in one file. Last edited by IdOp; 19th August 2019 at 02:00 PM. |
|
|||
Cron and email
No, that doesn't work. The backup script runs and then shutdown occurs but no mail is sent.
No matter. Your first suggestion works fine and that's good enough for me. Thanks again for your help. |
|
||||
Have you tried rewriting your script to sth. like this?
Code:
#!/bin/sh backup() { mount /dev/sd1a /mnt/ /usr/local/bin/rsync -avh --exclude-from=/home/stan/rsync.exclude /home/stan /mnt/ /usr/local/bin/rsync -avh /etc /mnt/ /usr/local/bin/rsync -avh /var //mnt/ cd /home/stan/ umount /mnt/ } backup | mail -s "backup log" root sleep 5 shutdown -p now |
|
|||
Cron and email
My apologies for taking so long to respond. I've been away for a few days and only got back last night.
I've tried out your script and it seems to work flawlessly. I'll be using it going forward. Thanks for taking the time and making the effort. It is appreciated. |
|
||||
No worries. Glad it works!
Besides, I basically didn't do anything. I just took IdOp's suggestion and streamlined it a little sprinkling a function call here and a few curly brackets there. |
|
||||
Oh I don't know. You had the idea to introduce an explicit mail command instead of relying on the cron output. That takes charge of the part that was going wrong and makes it happen when you want, and also could be done with everything in one file. Both good improvements!
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
syspatch cron job | bsdsource | OpenBSD General | 4 | 29th June 2018 04:05 PM |
cron newsyslog message | starbuck | FreeBSD General | 2 | 6th August 2008 07:33 PM |
Please help me automate getmail with cron | cssgalactic | FreeBSD General | 2 | 9th July 2008 10:13 PM |
Cronjob script does not run in cron | godfrank | FreeBSD General | 9 | 30th June 2008 12:41 AM |
Using sendmail in a cron job | erehwon | OpenBSD General | 6 | 15th May 2008 09:03 PM |