Wednesday 12 March 2014

Apple: Restart A Mac OS X Server Service With AppleScript

With the AppleScript below, you can restart any services of the Mac OS X Server. The AppleScript below particularly will stop and start the mail service every hour.

You can copy and paste it into AppleScript Editor, compile it and save it as an application. You can then run it. You need to run it from an administrator account and keep that user logged in.

If once an hour (every 3600 seconds) is too often, just change 3600 to however many seconds you want.

Be sure to change AdminPassword with the Admin user's actual password.
repeat
 
do shell script "/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin stop mail" password "AdminPassword" with administrator privileges

delay 60


do shell script "/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin start mail" password "AdminPassword" with administrator privileges


delay 3600


end repeat

Reference:
Mavericks mail server stops distributing group email after a few hours of usage
https://discussions.apple.com/message/24069163#24069163

No comments:

Post a Comment