Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,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 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[15,586 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 whomever posted them. This site is not responsible for what they say.
Anacron?
Authored by: mithras on Tue, May 3 2005 at 10:52AM PDT

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 Tue, May 3 2005 at 11:44AM PDT
You can use Anacron for the mac.

[ Reply to This | # ]
Anacron?
Authored by: sahilt on Tue, May 3 2005 at 12:04PM PDT
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 Tue, May 3 2005 at 12:37PM PDT
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 Tue, May 3 2005 at 2:09PM PDT
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: gaspode on Tue, May 3 2005 at 12:40PM PDT
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 Tue, May 3 2005 at 6:22PM PDT
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 Tue, May 3 2005 at 11:52PM PDT
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 Wed, May 4 2005 at 12:10AM PDT
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 Thu, May 5 2005 at 7:05PM PDT
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 Fri, May 6 2005 at 12:21PM PDT
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 Tue, May 17 2005 at 6:28PM PDT
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 Wed, Jun 15 2005 at 3:23PM PDT
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 Wed, May 4 2005 at 2:43AM PDT
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 Wed, May 4 2005 at 2:58AM PDT
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 Wed, May 4 2005 at 9:24AM PDT
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 Wed, May 4 2005 at 7:14PM PDT
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 Thu, May 5 2005 at 9:44AM PDT
...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 Fri, May 6 2005 at 11:35PM PDT

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 Sun, May 8 2005 at 8:23AM PDT
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 Tue, May 26 2009 at 9:59AM PDT
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 Tue, May 26 2009 at 10:49AM PDT
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 | # ]