Posts

Post not yet marked as solved
1 Replies
273 Views
Trying to automated running this shell script and getting the results. So I have a shell script: backup.sh -- finds latest backup time machine backup date, creates a file on the desktop called bkDate.txt then added the date into the file. #!/bin/sh enabled=`/usr/bin/defaults read /Library/Preferences/com.apple.TimeMachine AutoBackup` if [ "$enabled" == "1" ];then lastBackupTimestamp=`date -j -f "%a %b %d %T %Z %Y" "$(/usr/libexec/PlistBuddy -c "Print Destinations:0:SnapshotDates" /Library/Preferences/com.apple.TimeMachine.plist | tail -n 2 | head -n 1 | awk '{$1=$1};1')" "+%Y-%m-%d %H:%M:%S"` echo "$lastBackupTimestamp" else echo "<result>Disabled</result>" fi echo "$lastBackupTimestamp" > ~/Desktop/bkDate.txt If I run it manually through sh ~/Desktop/backup.sh it works if I use automator (shell or AppleScript) or crontab. It produces the file but the contents is empty. Trying to figure out why it's not letting me automate it and how would can I automate the file and output?
Posted
by syphon.
Last updated
.