Hi Keifer,

Depending on the version of OS X you’re using (hopefully it’s a recent one), 
you might have more reliable script execution using Launchd rather than Cron.

For your script, I would stick to bash as you seem to be combining AppleScript 
and shell script. Make the following text file:

#!/bin/sh
/usr/local/bin/brew update
/usr/localbin/brew upgrade tor
echo “script ran at `date`” >> /tmp/torupdate.log
exit 0

Make the file executable by typing sudo chmod +x (filename) in the terminal and 
pressing enter. You will be prompted for your password.

You can easily make a launchd plist file using the online zerowidth tool: 
http://launched.zerowidth.com/ <http://launched.zerowidth.com/> .  Include the 
complete path to the script you just made in the launchd plist file as the 
command. Every time it runs it will write to the log file at /tmp/torupdate.log 
which you can clear by restarting your Mac.

Drop your plist file into /Library/LaunchDaemons or ~/Library/LaunchDaemons and 
restart your computer to make it take effect.

If this works for you, you may want to start modifying the script to stop Tor 
as it is being upgraded, restart it afterwards and perhaps add some more 
logging or alerts.

Good luck!

S









> On 1 May 2018, at 18:58, Keifer Bly <[email protected]> wrote:
> 
> Hello,
> 
> So on Mac OS X, I am using crontab to automatically run a script I wrote for 
> Mac OS High Sierra to automatically update the tor relaying software every 
> day at 1am.
> 
> The cron command I am using is this: 0 1 * * * /Users/oldimac/Desktop/update\ 
> tor.scpt
> 
> The script I wrote seems to work fine for updating tor, however it seems to 
> have trouble updating homebrew.
> 
> Here are the contents of the script:
> 
> do shell script "$ which brew
> /usr/local/bin/brew update"
> do shell script "$ which brew
> /usr/local/bin/brew upgrade tor"
> end
> 
> 
> When the script is run, the output is this:
> 
> sh: $: command not found
> Error: tor 0.3.2.10 already installed
> 
> So it seems to be that it updates tor ok but when it tries to update homebrew 
> the error is “command not found”.
> 
> I previously tried do shell script “brew update” however that only turns to a 
> "command not found" error and only works in terminal but not AppleScript.
> 
> Also, after writing the crontab command, I launched crontab via terminal via 
> running “crontab” which loads to a blank Terminal screen. Do you know of a 
> way I can check the script actually ran?
> 
> Thank you very much.
> 
> 
> 
> 
> _______________________________________________
> tor-relays mailing list
> [email protected]
> https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________
tor-relays mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-relays

Reply via email to