Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Reschedule periodic maintenance tasks System 10.4
Tiger only hintMac OS X 10.4 has as changed the method by which the periodic system tasks periodic (daily, weekly, and monthly) are called. You can no longer change their execution time by modifying the system crontab. If you wish to change the times these tasks run, you will have to make changes to the following files. All live in /System/Library/LaunchDaemons, and each is named:
  • Daily: com.apple.periodic-daily.plist
  • Weekly: com.apple.periodic-weekly.plist
  • Monthly: com.apple.periodic-monthly.plist
Since these files are owned by root, the easiest way to change them is with sudo and your favorite command line text editor:
sudo pico System/Library/LaunchDaemons/com.apple.periodic-daily.plist
The relevant parts to change are:
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>15</integer>
Change these values to whatever you'd like.

[robg adds: Using sudo, I'd also recommend a backup of the files before you start, just in case...]
    •    
  • Currently 2.40 / 5
  You rated: 3 / 5 (5 votes cast)
 
[20,521 views]  

10.4: Reschedule periodic maintenance tasks | 22 comments | Create New Account
Click here to return to the '10.4: Reschedule periodic maintenance tasks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Anacron?
Authored by: mithras on May 03, '05 10:52:58AM

Does launchd do an anacron-like "catch-up" of actions that it's missed? Or is there a way to enable such functionality on a per-item basis?

---
--
Listen To My iTunes Library (6500+ songs, iTunes 4 required)

[ Reply to This | # ]

Anacron?
Authored by: luhmann on May 03, '05 11:44:03AM
You can use Anacron for the mac.

[ Reply to This | # ]
Anacron?
Authored by: sahilt on May 03, '05 12:04:51PM

It's not immediately clear how to setup Anacron to 'catch-up' tasks that are not run via cron (but instead via launchd). Does anyone want to write-up a basic HOWTO?

After all, it will be useful (especially for use iBook/Powerbook users), and certainly not more basic than instructions on removing Dashboard from the Dock. ;-)



[ Reply to This | # ]
launchd
Authored by: nick on May 03, '05 12:37:14PM

there is an option to run launchagents and launchdaemons not only at certain time, but periodically. i couldn't figure out, whether a periodic daemon gets started, if it was dued while the computer slept.



[ Reply to This | # ]
Anacron?
Authored by: mudpup on May 03, '05 02:09:46PM
On my lap top I run the cron jobs, manually when it's convenient.
Open termial

sudo sh /etc/daily
sudo sh /etc/weekly
sudo sh /etc/monthly


[ Reply to This | # ]
10.4: Reschedule periodic maintenance tasks
Authored by: deleted_user18 on May 03, '05 12:40:36PM

Yes you can use anacron. But this is not what we want.

We want to use Apples shiny launchd to start these jobs. Somebody has to figure out how to make these settings.



[ Reply to This | # ]
10.4: Reschedule periodic maintenance tasks
Authored by: akakie@acsalaska on May 03, '05 06:22:59PM

XJanitor.pl worked for me through 10.3.9, but the structure is now changed. I use a PowerBook G4 which is off at the critical times when maintenance runs. I need the "catch up" on missed tasks ability and I suppose many others do as well.

Does anyone know if Apple's new version includes the catch up capability? If not, I hope someone is working on it. It is probably beyond me.



[ Reply to This | # ]
XJanitor.pl
Authored by: googoo on May 03, '05 11:52:15PM

XJanitor.pl still works. It runs the periodic scripts directly (if needed). Just execute it from the terminal (or whatever method you normally use).

You cannot use cron anymore, though (unless you reconfigure to run it). If you want to run XJanitor.pl on a schedule, you will have to use launchd. I am sure we will read MUCH more on launchd soon.

-Mark



[ Reply to This | # ]
Cron does run
Authored by: googoo on May 04, '05 12:10:41AM

Let me correct myself: cron is running on Tiger without any need to reconfigure. I guess I should have tested it before saying that it did not run!

-Mark



[ Reply to This | # ]
Cron does run
Authored by: Ric_D on May 05, '05 07:05:41PM

Hmmm... well, I can see in Activity Monitor that cron is running, but my jobs in /etc/crontab are not executing. This is driving me crazy...



[ Reply to This | # ]
Cron does run
Authored by: m1dg3 on May 06, '05 12:21:07PM

The Tiger install removes all your entries from /etc/crontab.

If you put them back in they will run.



[ Reply to This | # ]
XJanitor.pl
Authored by: macmaxbh on May 17, '05 06:28:15PM

It doesn't work for me--if I check the Xjanitor.out log I get:
sh: line 1: periodic: command not found



[ Reply to This | # ]
10.4: Reschedule periodic maintenance tasks
Authored by: derekhed on Jun 15, '05 03:23:29PM

I would like to re-enable XJanitor to run on my laptop, but I am worried that the launchd process will still run the maintenance tasks if I leave it running all night. I assume that I would need to disable the launchd part that fires off the maintenance tasks if I am going to use XJanitor. I have some log scripts that rely on the logs being there, such as webalizer.

Has anyone addressed this issue?



[ Reply to This | # ]
Launchd manual settings
Authored by: ukkarhu on May 04, '05 02:43:04AM
Launchd runs the periodic scripts automagically. Look in /var/log for daily.out, weekly.out and monthly.out. Check the datestamp of the log files to confirm when they ran. You can also use launchd to run these manually i.e.

sudo launchd periodic daily
Andy P.

[ Reply to This | # ]
Launchd manual settings
Authored by: ukkarhu on May 04, '05 02:58:07AM
Although the above works, by looking in the man pages, it seems the correct way to manually start daemons is:

sudo launchctl start com.apple.periodic-daily
where the phrase after 'start' is the label as defined in the xml plist file and displayed with the command:

sudo launchctl list


[ Reply to This | # ]
used launchd for ichatlocationscript and works fine
Authored by: nick on May 04, '05 09:24:15AM
i configured launchd to periodically run an applescript that changes the ichatstatus to my current network-location. it works fine. i made this plist-file in ~/Library/LaunchAgents :
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Debug</key>
        <false/>
        <key>Label</key>
        <string>iChatLocation</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Nice</key>
        <integer>10</integer>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/bin/osascript</string>
                <string>/Users/niko/bin/ichatlocation.scpt</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>ServiceDescription</key>
        <string>Change iChat Location to Network</string>
        <key>StartInterval</key>
        <integer>180</integer>
        <key>UserName</key>
        <string>niko</string>
</dict>
</plist>
it is labeled "iChatLocation", runs with low IO priority and with nice 10, starts an applescript in the bin-folder in my homedir, runs at load (maybe i wouldn't need that) and then every 180 seconds with my (niko) userrights. even better of course would be, if s/o figured out how to run stuff at network-changes. i started it with:
Nikomat:~ niko$ launchctl load Library/LaunchAgents/iChatLocation.plist
i can check, that its running:
Nikomat:~ niko$ launchctl list
iChatLocation
Nikomat:~ niko$


[ Reply to This | # ]
configd better than launchd
Authored by: hughescr on May 04, '05 07:14:18PM
The way you run stuff at network switches rather than periodically is to hook into configd, not launchd. See here for details.

[ Reply to This | # ]
configd better than launchd / right...
Authored by: nick on May 05, '05 09:44:50AM

...but when i think about it... perhaps in my case its better to run stuff periodically as the script exits anyway if nothing has changed AND more important it relies on ichat having logged in... which usually isn't the case immediatelly after the networkchange, but some 10 seconds later...



[ Reply to This | # ]
used launchd for ichatlocationscript and works fine
Authored by: jonbauman on May 06, '05 11:35:17PM

You actually don't need to set the user explicitly if you put it in your own ~/Library/LaunchAgents directory. The default is to run as the user that added the agent to launchd.

One thing I can't figure out is how to run commands with spaces in the name. I've tried quoting, no quoting, and backslash escaping, but nothing seems to work

---
jon

[ Reply to This | # ]

10.4: Reschedule periodic maintenance tasks
Authored by: gsgm on May 08, '05 08:23:55AM
When I first tried the hint, I ended up opening a blank file. I believe the actual command should be;
sudo pico /System/Library/LaunchDaemons/com.apple.periodic-daily.plist
(Note the "/" in front of System)

[ Reply to This | # ]
use defaults to reset
Authored by: joelbruner on May 26, '09 09:59:34AM
Here's the settings I use at work, I flipped everything from am to pm and changed the weekly to run on Monday instead of Saturday
sudo defaults write /System/Library/LaunchDaemons/com.apple.periodic-daily StartCalendarInterval -dict-add 'Hour' -int '15'
sudo defaults write /System/Library/LaunchDaemons/com.apple.periodic-weekly StartCalendarInterval -dict-add 'Hour' -int '15'
sudo defaults write /System/Library/LaunchDaemons/com.apple.periodic-weekly StartCalendarInterval -dict-add 'Weekday' -int '1'
sudo defaults write /System/Library/LaunchDaemons/com.apple.periodic-monthly StartCalendarInterval -dict-add 'Hour' -int '13'


[ Reply to This | # ]
reset file perms
Authored by: joelbruner on May 26, '09 10:49:10AM
Forgot that defaults will trash the permissions on a file, so add back read ability for group and others
sudo chmod go+r /System/Library/LaunchDaemons/com.apple.periodic-*


[ Reply to This | # ]