Contribute  :  Advanced Search  :  Directory  :  Forum  :  FAQ's  :  My Downloads  :  Links  :  Polls  
AFP548 Changing the world one server at a time.
Welcome to AFP548
Thursday, July 29 2010 @ 09:32 am MDT
Advertising

 Forum Index > Questions and Answers > Updates New Topic Post Reply
 Cron and softwareupdate
 |  Printable Version
Anonymous: Adam
 Sunday, June 12 2005 @ 06:41 pm MDT (Read 2953 times)  


I have a crontab that I set up with Cronix (http://www.versiontracker.com/dyn/moreinfo/macosx/9478), a GUI editor for cron in OS X. I am trying to get my Mac clients to automatically update from the Apple software update server with no user interaction. softwareupdate -a -i will do this from the command line. It is hard to test my crontab with the download and install flags on , becuase I will run out of updates to install eventually, I am testing my cron tab with softwareupdate -schedule on. This will change the "check for updates" check box in System Preferences->Software Update. To see it change from unchecked to checked you must quit System Preferences and reopen. As a cron task it does not work.

Troubleshooting steps taken:

I have confirmed that when I run softwareupdate --schedule on from the command line it works.

I have confirmed that the cron task I set up is getting run by replacing softwareupdate --schedule on with a script that writes a file to my desktop so I can visual confirm the cron task is working.

I have tried including softwareupdate --schedule on in a script that also includes a write of some text to a file. Then calling the script from cron. The text gets written, but the softwareupdate --schedule on does not set the flag.

Cronix even has a feature to force a script to "Run Now". And it works fine then.

I am running 10.4.1.

Nothing is written to any log I can find.

Here is my crontab
# minute hour mday month wday who command
51 14 * * * root /usr/sbin/softwareupdate -- schedule on
and I also tried
51 14 * * * root softwareupdate -- schedule on
an Apple systems engineer suggested not running it as root, but as a normal user
12 3 * * * /Users/adam/Desktop/SU_On_Script

I am out of ideas. An Apple systems engenerier who tried to help me, and I spoke with John Detroye (http://homepage.mac.com/johnd/) at a conference. They both agreed it should be possible.

I would appreciate any ideas that anyone may have. However, I am so perplexed by this problem and how simple it is to set up that I am asking someone to please give it a try.

1. Open System Preferences->Software Update and set "check for updates" to false. Quit System Preferences.
2. From the command line run softwareupdate --schedule on
3. Open System Preferences->Software Update and visually confirm that this command changes the flag to true. For me it does.
4. Set check for updates to false. Quit System Preferences.
5. Set up a cron task to run softwareupdate --schedule on, or for that matter the real money maker, with caution, softwareupdate -a -i.
6. Does it work? Shouldn't it?


Software update usage, also has a man page.
usage: softwareupdate [ ...]

-l | --list List all appropriate updates
-d | --download Download Only
-i | --install Install


 
Quote
Anonymous: geekahertz
 Sunday, June 12 2005 @ 09:00 pm MDT  


Geekahertz Library
http://geekahertz.org/library/index.php?subaction=showfull&id=1095538011&archive=&start_from=&ucat=2&

OS X has some very powerful features under the hood. I recently set up my university's OS X computers to auto update themselves every Friday.

Software Update has the feature to download the updates, but does not offer to have everything automatically installed for you at a specific time. Luckily with OS X you have cron [http://www.hmug.org/man/8/cron.html] to help you.

To run the updates unattended from the command line all that is needed is:


softwareupdate -i -a


This works pretty well except when you have to click 'accept' on an EULA. To take care of this problem you do this:


COMMAND_LINE_INSTALL=1 export COMMAND_LINE_INSTALL;softwareupdate -i -a


Now, we want this to be done automatically at a specific time and date, so we have to add the following into /etc/crontab

00 18 * * 5 root
COMMAND_LINE_INSTALL=1 export COMMAND_LINE_INSTALL;/usr/sbin/softwareupdate -i -a


note: That entire thing is on one line.

The previous cron entry works great, but there is really no way of knowing whether or not it ran without doing some digging. We need to create a log of the output that softwareupdate spews out. We also want the computer to reboot after the updates are completed. To do this we'll add the following:

COMMAND_LINE_INSTALL=1 export COMMAND_LINE_INSTALL;/usr/sbin/softwareupdate -i -a 2>&1 >> /var/log/auto_update.log;/sbin/reboot


Adding the '2>&1 >> /var/log/auto_update.log' simply redirects all the output from softwareupdate into the file auto_update.log.

To sum up everything: first, we get rid of the EULA problem. Second, we run softwareupdate and have all of the output redirected into the file /var/log/auto_update.log. Finally, we reboot the computer, which is required by a lot of the updates.

There are a lot of ways to set your computer up to do this, but I have found that the easiest way is just to add everything into /etc/crontab. It ends up being a lot cleaner and easier to install onto multiple computers.


Here is a very simple script I wrote that will install the cron entries for you. You need to edit the first two fields to run this when you desire. It's currently set to run at 6pm every Friday night.


If you have any questions feel free to email me at scorchen [at] geekahertz [dot] org Please visit geekahertz for updates.


 
Quote
tbone
 Friday, June 24 2005 @ 02:49 pm MDT  
Forum Help Desk
Help Desk

Status: offline

Registered: 02/17/05
Posts: 36

Under 10.3 we accomplished updates with

"30 11 * * * /usr/sbin/softwareupdate --install --req "

Aside from rolling our own Quicktime updates to bypass the popups that worked fine.

Trent


 
Profile Email
Quote
Content generated in: 0.11 seconds
New Topic Post Reply



 All times are MDT. The time is now 09:32 am.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Full HTML Allowed 
Censored Content