![]() |
I understand that you've been running this script from the command-line as 'root'.
Are you sure that the CCC environment runs the script as 'root' ? If not, permission problems are an obvious thing to look at. |
I've tried running it both as "me" and as root. Should I try running it as some other user?
|
I don't really think it'll help, but I would try the code without the trailing & as that seems to be the only difference between the older working and the current non-working code.
The problem isn't in mail directly as you've demonstrated merely tailing the contents into a file doesn't work. The other difference is when you run the code manually, there is a controlling terminal. When run via Postflight, there isn't. Maybe a nohup is needed. |
This has to be run with the trailing & because it has to run asynchronously. Otherwise the disk gets unmounted before CCC is finished causing CCC to exit with an error.
Where would the 'nohup' go? |
It Finally Works
Here's the version that works:
Code:
(sleep 60; diskutil unmount 02352EBA-9C0A-3992-AA28-BBCBC7A29367 >> /library/logs/CCC.log 2>&1; sleep 10; tail -n 25 /library/logs/CCC.log | mail -s "CCC" root) &Oddly, although this script works, it fails to unmount the disk: Code:
07/31 06:56:54 Running postflight script: /usr/share/Clone.sh |
Quote:
( sleep 60; diskutil unmount 02352EBA-9C0A-3992-AA28-BBCBC7A29367 >> /library/logs/CCC.log 2>&1; sleep 10; tail -n 25 /library/logs/CCC.log | mail -s "CCC" root ) & The & is clearly outside the () and is just putting everything inside the () in the background. The first thing happening is the program sleeps for 60 seconds for no apparent reason. AFTER sleeping, it unmounts the drive putting both stdout and stderr into your log file. I would really expect diskutil to NOT return until it has finished, but a short sleep can't hurt. You said this worked, but failed to unmount the drive. Did you have anything else open on the drive when you ran the script?. When you were testing it before, were you waiting 3 minutes for all the sleeps to expire before deciding it hadn't worked? The nohup would go at the top of script right below the opening line, but I don't think now that is your problem. |
Quote:
Quote:
Quote:
CCC ran as a scheduled task last night. From the log file you can see that the postflight script ran. But, it neither unmounted the drive nor sent e-mail. This is driving me nuts: Code:
08/01 04:05:43 Running postflight script: /usr/share/Clone.sh |
Why not simply eliminate the problem entirely? Skip the CCC postflight step and do the entire job as a regular shell script. CCC is little more than a wrapper around a couple of commands like hdiutil and rsync - duplicating it's functionality in a shell script is very easy.
|
Quote:
If I don't even have the brains to get a one line shell script to run I can't imagine doing something as complex as cloning a drive. Remember, this is the "Unix Newcomers" subforum….. |
Cloning a drive is easy! And you've already worked out some essential concepts.
But lets back up a bit - what is your primary goal? A bootable backup or a restorable image? Is this on a personal machine or on a server? |
This is on our main personal machine. My goal is a bootable backup. I run CCC automatically once a week. I want to be notified via e-mail that CCC ran. I want to have the backup drive mount only on demand and unmount when CCC is done.
I want the backup drives (CCC and Time Machine) to be unmounted when not in use because it makes a significant improvement in the speed of loading file dialog boxes. |
The bootable backup portion of CCC will do something like this:
(note carefully the spacing around the single / ) rzync -aqAXx --del --log-file=/var/log/myrsync.log / /Volumes/backupVolume As for the mount/unmount part, Bombich does some fancy things to hide the process from the Finder - no need to duplicate. To mount an unmounted volume we need to find it's device name, diskutil plus some string massaging: Code:
mountThis=`diskutil list | grep iWantThisVolume | sed -e 's/.*disk\([0-9].*\)/disk\1/'` |
AMO - Thanks for this. I will have a look and see what I can do. Right now the monitor for that machine (a MacMini) is in for repairs and I'm doing everything via VNC from an ancient iMac. When I get the monitor back I'll give it a shot.
I'm still curious as to why the script in the OP doesn't work as expected. |
Why don't you enable remote login on the Mini and use Terminal and ssh? Much faster than VNC to the other desktop then using Terminal there.
|
Good idea. I've got SSH enabled with public key authentication.
|
The long standing way to make sure disk io was completed in the past was to issue "sync; sync; sync", not sleeping and hoping it magically got done. I'd be hard pressed to believe that no longer works on a system that is "certified unix".
|
Quote:
Code:
mdutil -i off /Volumes/Clorox/ | mail -s "MDS Off" rootCode:
Volume Clorox on disk1s2 failed to unmountThere can be nothing using this volume as it is not mounted until just before CCC runs. No other process uses the volume. I remain baffled. |
You might try using 'lsof' to check for open files on that volume.
|
Quote:
Code:
notifyd 26 root 15r DIR 14,5 7412 607655 /Volumes/Clorox/System/Library/Extensions |
This is too weird. If I put 'sleep 60' as follows:
Code:
(sleep 60; diskutil unmount "$2" >> /Library/Logs/CCC.log 2>&1; sleep 1; tail -n 25 /Library/Logs/CCC.log | mail -s "CCC" root) &mail SUCCEEDS If I put 'sleep 120' as follows: Code:
(sleep 120; diskutil unmount "$2" >> /Library/Logs/CCC.log 2>&1; sleep 1; tail -n 25 /Library/Logs/CCC.log | mail -s "CCC" root) &mail FAILS Here's what was happening with the volume (lsof) just before the 'sleep' command: Code:
notifyd 26 root 15r DIR 14,5 7412 607655 /Volumes/Clorox/System/Library/Extensions |
| All times are GMT -5. The time now is 10:39 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.