How do I make a shell script based on a command line and have it run every day on a mac?

I hope someone can help me as this is my first attempt to make a shell script.

I have set up an Adobe Software Update server. Using the I can manually send a command to the Adobe Update Software Setup Tool (AUSST) to check if there are new software updates at Adobe, which are then downloaded and available to our users.

The command line is:
sudo /Users/macpostur/Desktop/AUSST/AdobeUpdateServerSetupTool  --root=/Library/WebServer/Documents/Adobe --incremental

It asks for the password and then runs.

I would like to make this command run once every day at 23:00, preferably as a shell script run by launchd. I bought Lingon and I just downloaded LaunchControl but I am getting nowhere. Errors I get when this is run have error codes 126, which seem to say that permissions are not ok.

The thing is I don't know what should be inside the .sh file.


1. What text from the command should be inside the .sh text file? Complete.
2. What permissions should I set for the .sh file? chmod + what?
3. Where should I keep the .sh file?
4. What settings should I set in Lingon or LaunchControl? Or more specifically: How do I run this every day?
LVL 22
Sigurdur ArmannssonDesigner Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This article on Cron Scripts should help on the issue of running the script on a daily basis:
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Christopher Jay WolffWiggle My Legs, OwnerCommented:
New to this also.  Here is a pretty good guide for scripting

which yields the following...


1.  the command should be just like you type it when it works.



It sounds like you need to set the execute permissions for your .sh file to be able to run it.  The below is under "Creating and Running a Script"

2.1.3. Executing the script

The script should have execute permissions for the correct owners in order to be runnable. When setting permissions, check that you really obtained the permissions that you want. When this is done, the script can run like any other command:

willy:~/scripts> chmod u+x

willy:~/scripts> ls -l
-rwxrw-r--    1 willy      willy            456 Dec 24 17:11


Write this script for yourself as well. It might be a good idea to create a directory ~/scripts to hold your scripts. Add the directory to the contents of the PATH variable:

export PATH="$PATH:~/scripts"

If you are just getting started with Bash, use a text editor that uses different colours for different shell constructs. Syntax highlighting is supported by vim, gvim, (x)emacs, kwrite and many other editors; check the documentation of your favorite editor.



Why not just use launchd?  Make sure the launchdaemon is started.  As discussed here.

and here...

and here...

and some examples
Christopher Jay WolffWiggle My Legs, OwnerCommented:
launchd is backwards compatible with Cron.
Sigurdur ArmannssonDesigner Author Commented:
Thanks guys. Plenty to check out. Let me read and try and I'll be back.
Don't create a script with sudo in it.  Create a cron that's run as root and you won't have to enter a password for sudo.

If you're using launchd, you shouldn't have to use sudo either.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sigurdur ArmannssonDesigner Author Commented:
I am distributing the points between you three for the information.
I have tried some of what I have read in the links and also some based on the advice but I am not there yet. The links you gave are helpful and hopefully they lead to a solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.