Post not yet marked as solved
Post marked as unsolved with 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?