I have the requirement to manually run the OSX maintenance scripts in OSX (Lion / Mountain Lion). I would like to create a completely stand alone application that would achieve the following goals:

  • run the terminal command : sudo periodic daily weekly monthly
  • Be executable via Finder
  • Be standalone (a single file is all that is needed to execute the process so that a non technically inclined user may simple double click to run said command)
  • Be portable (copy a single file to a USB flash drive or other portable media)
  • Be able to be run on Mac's running OSX Lion or Mountain Lion

I do not necessarily need to see the results upon completion of execution as I can always go to /var/log directory to find out but if someone knows of a way to eliminate this extra step all the better.

I found this response but it does not meet all the requirements. I am not a coder / programmer but I can (and I am willing) to follow straightforward instructions in order to achieve my goals.

  • What specifically in the linked response is not appropriate for your usage other than the actual command?
    – zwerdlds
    Mar 5, 2013 at 17:40
  • I do not need users to see a terminal window and I would prefer to have a standalone .app vs a .command
    – Mort
    Mar 5, 2013 at 17:47
  • 1
    Out of curiosity and assuming the given example (sudo periodic) is the intended command: Why do you want the user to able to kick this off manually? OS X runs this automatically for you already (and even remembers to run it later if the computer was turned off at the pre-defined time).
    – nohillside
    Mar 5, 2013 at 18:38
  • On some Mac's in our company due to various reasons (there are a few) the scripts may be delayed but up to as much as a couple of months to execute.
    – Mort
    Mar 5, 2013 at 18:43

5 Answers 5


Create an Automator application that calls up an AppleScript. You will need to enter administrative credentials each time still, as I'm sure the password could be different on each system you use.

enter image description here

  • If you tell to use administrator privileges you don't need to say run sudo and run periodic directly
    – Eir Nym
    Mar 7, 2013 at 8:16
  • You're right. That was me being sloppy. I'll update the screenshot momentarily.
    – bispymusic
    Mar 7, 2013 at 13:04
  • @bispymusic This seems to be what I'm looking for, however, when I try and build the script and execute it I get the following error: Apple Script Error
    – Mort
    Mar 7, 2013 at 17:59
  • Please see the above comment. The AppleScript referenced in Automator does not need the word "sudo" in it, as it is already told to run with Administrator privileges. I am at work, on a PC, so I haven't been able to update the screenshot yet.
    – bispymusic
    Mar 7, 2013 at 19:02
  • With the minor tweak this script does exactly what I was looking for. Thanks to @bispymusic
    – Mort
    Mar 8, 2013 at 15:51

The answer by bispymusic should work well, but an even simpler answer (fewer layers of program to launch) would be to open AppleScript Editor and create a New script. The script is the same as above:

 do shell script "periodic daily weekly monthly" with administrator privileges

Save the script as an application. Done. Automator is great, but in this case, it's just calling an AppleScript, so we can cut out the automator middleman and just create an AppleScript directly.

This should meet all five of your requirements, with the technical caveat that both the automator script and the AppleScript application are technically folders and not single file. To the non-technical end user, however, they do behave like single files and can be double-clicked to run, dragged and dropped, etc.

enter image description here

  • This is also useful. I can use the for future requirements as well.
    – Mort
    Mar 8, 2013 at 15:52
  • 2
    Good call @Daniel. I go to Automator so often for simple tasks that I didn't step back and realize that I could've done this purely in AppleScript.
    – bispymusic
    Mar 8, 2013 at 16:12
  • @bispymusic Often an Automator wrapper for a one-liner is helpful. If you want to bind a one-line AppleScript to a keyboard shortcut, a Service is often the easiest way to go. If you want a script automatically applied to files dropped into a folder, again, Automator. This case is the exception where Automator doesn't add value. But your script is great; that's why I upvoted it.
    – Daniel
    Mar 8, 2013 at 17:14

Here's a way to run a script with administrator privileges and not have to enter password each time (can't remember where I found it) :

property userpassword : "" -- <<< !!! DO NOT FILL !!! Script will ask if needed.

-- Will ask for password on first run

-- Now userpassword contains the password filled the first time
-- You can for example do :
-- do shell script "sudo ipfw list" password userpassword with administrator privileges

-- Your script here

on getPassword()
    if userpassword is "" then
        display dialog "Please enter your password:" default answer "" with hidden answer
        set userpassword to text returned of result
        -- The repeat section below is an optional error checking routine to ensure the password is valid
        set the_password to "Undefined"
        repeat until the_password is "Correct"
                set theFinderPID to do shell script "ps -axww | /usr/bin/grep '[/]Finder'| awk '{print $1}' | head -1"
                do shell script "renice 1 " & theFinderPID password userpassword with administrator privileges
                do shell script "renice 0 " & theFinderPID password userpassword with administrator privileges
                set the_password to "Correct"
            on error
                display dialog "Wrong password :" default answer "" with hidden answer
                set userpassword to text returned of result
            end try
        end repeat
    end if
end getPassword
  • You can accomplish the same thing by modifying my AppleScript to do shell script "periodic daily weekly monthly" user name "insertusernamehere" password "insertpasswordhere" with administrator privileges. Both solutions, however, result in your password being stored in plain text in the accompanying script.
    – bispymusic
    Mar 8, 2013 at 19:19
  • 1
    No, here, the password is not hard coded in the script. It will be asked, checked and remembered on the user mac, more like a cookie.
    – Bibou
    Mar 8, 2013 at 19:39
  • @Bibou I'm not sure I understand. How is the password being encrypted or hidden in the actual script in this method? It seems to me like bispymusic is correct in that it's being stored as plain text within the script or am I missing something?
    – Mort
    Mar 8, 2013 at 20:06
  • You're right. I guess I've never looked into AppleScript properties. Now I'm on a mission to find where in the script bundle it's stored! Very useful!
    – bispymusic
    Mar 8, 2013 at 20:09
  • 1
    It is saved it the .scpt but not in plain text. It is not encrypted either, but it is harder to retrieve it than if coded in the script like : set mypassword to "something".
    – Bibou
    Mar 11, 2013 at 8:36

Sounds like what you need is Platypus, which lets you create application wrappers around scripts.


I do not know if you need this stuff anymore or not. Could cause more problems than the app cures. Look at this page for suggestions. The page could be out of date. http://www.thexlab.com/faqs/maintscripts.html

"Maintenance is a System Maintenance and Cleaning utility. It allows you to run miscellaneous tasks of system maintenance: repair permissions, run periodic scripts, reset Spotlight's Index, rebuild the LaunchServices database, delete Application, Font and System cache, and check the status of the hard disk."


  • Although it's not exactly what I had in mine it's still a workable solution to my issue, thanks for the suggestion.
    – Mort
    Mar 7, 2013 at 17:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .