How to Run a Shell Script Every Day on a Mac
Power Manager can be used to automatically run a shell script each day. Shell scripts can be used to perform tasks that are difficult, or impossible, to achieve using the graphical Mac OS X interface.
Power Manager can be used to automatically run a shell script each day. Shell scripts can be used to perform tasks that are difficult, or impossible, to achieve using the graphical Mac OS X interface.
Let’s walk through how to schedule a shell script to run once a day. Our shell script will mount a shared disk hosted on a Windows computer.
Create a Scheduled Shell Script
Launch System Preferences and select Power Manager.
Click Add… to create a new event.
Choose the template Run a script daily.
Click Continue to the Script step.
Copy and paste your shell script into the Script step.
#!/bin/sh mount_smbfs //dssw@winserver.local/share /Volumes/share
The shell script can be run as the root user, as a normal user, or even as whoever is currently logged in at the time. For this script, we have set the Environment to Super User (root).
Click Continue to the When step.
Adjust the time and days to read 9:00, with Monday through Sunday selected.
Continue through the remaining steps until your event is created.
With these steps completed, your shell script is now ready. Power Manager will perform the event and run your script once each day at 9:00.
If needed, Power Manager will automatically wake up your Mac in order to perform your daily shell script.