
:max_bytes(150000):strip_icc()/017-control-mac-with-voice-commands-4114186-cb2def475d414000ac6043c408887234.jpg)
Users/USERNAME/Path_to_Scripts/shutdown24.shĬopy this file to /Library/LaunchDaemons and then load it to launchd: Let's assume that we called the bash script shutdown24.sh so we will call our. plist that defines the job (similar to Task Scheduler) in Windows. What you need is to utilize lauchd and create a. So, I'm going to assume you want it run at midnight so you don't inadvertently shutdown the machine while people are working. This is not recommended because if for some reason the computer was turned on at 10:00am (because the person was late, for example) you don't want it shutting down at 10:00am the next morning when they are in the middle of their work.

If you want to use a voice other than your system's default add ' using' after it, and then.

When do you want to evaluate this? Technically, your could have this script run every hour (or even ever minute) to evaluate if the computer has been up for 24 hours. With this command, your Mac can say anything you type just remember to place the text in quote marks. Make sure you set the script as executable or it won't run: #Get the uptime days and assign it to a variable So, the number that we are interested is the "20" which we will evaluate against our condition of "1 day" #!/bin/bash If you execute the command by itself, it will tell you how long the machine has been up: $ uptimeĦ:08 up 20 days, 21:09, 4 users, load averages: 1.09 1.29 1.36 You can do this with a simple bash script, the uptime command and launchd. $ is unnecessary on arithmetic variables so $(( $CURR_TIME - $BOOT_TIME )) should be $(( CURR_TIME - BOOT_TIME ))
SHUTDOWN MAC VOICE COMMAND APPLESCRIPT CODE
The ping exit code check can be done directly in the if statement. So, change your crontab entry to something like this 30 23 * * * /Users/gunter/documents/remoteshutdown.sh > /Users/gunter/documents/remoteshutdown.logĪnd a couple other bash shell tips that I've changed in the script This will record the echo commands to the log file so you know what is happening.
SHUTDOWN MAC VOICE COMMAND APPLESCRIPT FULL
