Right, enough talk ... issue the following commands in Terminal unless otherwise specified. Note that scripts that have #!/bin/sh at the top need that as the first line.
Step 1:Create the Startup Item:
$ sudo mkdir -p /Library/StartupItems/Periodic
$ cd /Library/StartupItems/Periodic
$ sudo pico Periodic
Now copy and paste this code into pico. Press Control-X to exit pico (answering "Y" when asked to save). Now type the following commands:
$ sudo chmod +x Periodic
$ sudo pico StartupParameters.plist
Paste the following into pico and then exit as above.
{
Description = "Task: /usr/sbin/periodic [daily | weekly | monthly]";
Provides = ("Daily", "Weekly", "Monthly");
Requires = ("DirectoryServices", "Disks", "Network Time");
Uses = ("NFS");
OrderPreference = "Last";
Messages =
{
start = "Starting Periodic";
stop = "Stopping Periodic";
};
}
Step 2: add /etc/weekly.local script:This will help with our other scripts pattern matching for weeks:
$ sudo chmod +x /etc/weekly.local
$ sudo pico /etc/weekly.local
Paste in the following code, exiting and saving as before:
#!/bin/sh
theLog="/var/log/weekly.out"
thisWeek=`date '+%U'`
thisYear=`date '+%Y'`
if [ ! -f $theLog ]; then
touch $theLog
fi
echo "Year:$thisYear Week:$thisWeek [`date '+%a %b %e %H:%M:%S %Z'`]" >> $theLog
That's it. Now each time you reboot, the startup item Periodic will check to see whether it needs to run a maintenance task that was skipped.
[robg adds: I haven't tested this one...]

