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

XJanitor.pl intelligently runs required maintenance tasks System
If your Mac isn't on for 24 hours a day, every day, then your system maintenance scripts are not getting run in a timely manner. There are a number of solutions out there to work around this, but most require your active participation at some point. The free XJanitor.pl perl script, however, does not.

What Xjanitor does is at a specified interval (I use a quarter after the hour, each hour), it checks to see if the output logs of the periodic scripts have been updated within an appropriate time frame (daily, weekly, monthly). If not, it runs them. It is fairly easy to install, except for two things. One, you have to make the script executable. Secondly, you have to adjust the cron tab. The web site for the script tells you how to do both of these steps via the terminal.

However, I found that the cron-tab part could be done much easier via Cronnix, which has previously been mentioned on OSXhints. It is important, however, that the "user" for running this task be "system" and not "username" so that it runs as root. Otherwise, it won't have permissions.

[robg adds: We've run a couple hints (1, 2) discussing this before, but this one's different enough to merit a hint of its own. The intelligence of the script means that you won't have to "over-run" your weekly or monthly scripts just to make sure they're getting done. Since the maintenance tasks run at most 'daily,' I would think a cron task set up to check once per day would be sufficient to insure that all maintenance is being performed. Nice solution!]
    •    
  • Currently 2.00 / 5
  You rated: 5 / 5 (5 votes cast)
 
[8,675 views]  

XJanitor.pl intelligently runs required maintenance tasks | 16 comments | Create New Account
Click here to return to the 'XJanitor.pl intelligently runs required maintenance tasks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
CronAid - already done
Authored by: Jacques on Mar 20, '03 10:32:39AM

A simple installation of CronAid <http://www.versiontracker.com/dyn/moreinfo/macosx/13803> has been doing this for quite some time, with no special install instructions.



[ Reply to This | # ]
CronAid - already done
Authored by: luhmann on Mar 20, '03 11:26:38AM

CronAid is shareware - this is freeware. It really isn't hard to set up at all - takes less than a minute. Although it does look like they both do the same thing.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: r0adrage on Mar 20, '03 02:20:01PM

Just wanted to point out that checking it once daily, as rob suggested in his note, probably would not work. The "daily" events are already set up to check once per day, but if the computer is off it doesn't get run. The point of this type of software is to check often, in order to insure that at least one of the checks will happen when the computer is on.

I would agree that checking every 15 minutes is excessive, but only checking once a day would only marginally increase the chances of the events being run.

A better solution would be to activate XJanitor on a "wake up" event (via AppleScript, perhaps?). So when you wake your computer from sleep, one of the things it does is to check the periodic events and run them if needed. That would alleviate the need to constantly poll, and you would only spend those cycles on the check when the computer isn't doing anyhing yet.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: luhmann on Mar 20, '03 03:34:34PM

I have Xjanitor set to check at 15 minutes after the hour - this is once an hour. It doesn't take up any resources at all when it checks. It simply checks the modification dates of the logs for the periodic scripts. If they haven't been run in the appropriate time frame then it runs them. Even if your computer is asleep a lot, the chances are that at least once a day it is on at 15 minutes after the hour. It seems like a reasonable solution to me. Apple, on the other hand, has it set to run at a specified time in the middle of the night when your laptop is probably off or asleep.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: luhmann on Mar 20, '03 03:36:35PM

Addendum: I personally would rather not have a surge of activity on my comptuer when it wakes from sleep or turns on. Usually then is when I need to use it the most and I want it to be quick.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: klktrk on Mar 20, '03 04:45:51PM
"A better solution would be to activate XJanitor on a "wake up" event (via AppleScript, perhaps?). So when you wake your computer from sleep, one of the things it does is to check the periodic events and run them if needed."

The problem is that the maintenance tasks need to be run as root. That's why the system cron should trigger them. To run them on wakeup or at another time triggered by the user would require authorizing the maintenance with an admin user password. That would quickly become annoying.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: triplef on Mar 25, '03 02:37:55PM

A workaround for this problem would be a setuid'ed command line tool.



[ Reply to This | # ]
XJanitor.pl and Konfabulator
Authored by: skyhuv on Mar 20, '03 07:21:39PM

Konfabulator would be a perfect thing to initiate the XJanitor script...



[ Reply to This | # ]
Run XJanitor.pl 3 times per day...
Authored by: pmtav on Mar 28, '03 02:26:29PM
Rather than running the script hourly or daily, you can have the script run two or three times a day, as the script's author suggests on his page:

"For example, for some people it might be enough to just check three times a day, morning, afternoon, and evening, like this:
15 9,15,21 * * * root /Users/yourusername/Library/Scripts/Xjanitor.pl"

that would have the script run at 9:15 AM, 3:15 PM and 9:15 PM... that is adequate enought for me... without having it run each hour.

[ Reply to This | # ]

XJanitor.pl intelligently runs required maintenance tasks
Authored by: aubreyapple on Mar 20, '03 05:26:42PM

If you want to run this at startup, I created a startupItems
entry. Disclaimer: Use this at your own risk. Know how to
do Safe Mode or single user to remove! To use, download
http://homepage.mac.com/aubreyapple/XJanitor.tgz

cd /Library/StartupItems
sudo tar xfz [pathto XJanitor.tgz]

No crontab entries are needed with this method.

As 'luhman' said, some may not want this running on startup.
Thanks and acknowledgement to the originator of XJanitor: Kristofer Widholm



[ Reply to This | # ]
Don't forget anacron, too
Authored by: imacusr on Mar 20, '03 07:23:25PM

For those using fink, there's also the <b>anacron</b> package, which was designed specificaly for this sort of thing. Hopefully, Apple will update OS X to include it or something similar in functionality for us laptop users.



[ Reply to This | # ]
Don't forget anacron, too
Authored by: porkchop_d_clown on Mar 21, '03 08:34:33AM

Since the official Apple X11 package, Anacron is the only reason I have fink installed on my system!


---
--
knock knock



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: UMD on Aug 21, '03 09:40:12AM

Well for me as a laptop user there a certain things why i think this hint is a bit problematic:

1. when my powerbook is running on battery i don't want to have run the maintance tasks cause they could use a lot of power. You could change that by preceding the periodic commands with @AppleNotOnBattery in the crontab file

2. i don't want have the maintance tasks to run when i'am actually working on my powerbook, so it would be a great helper if the scripts would check out if the screensaver is running and for how long or if the scripts would check out the cpu usage.

well macaroni does that all but it is no freeware.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: elmimmo on Aug 21, '03 05:52:10PM

Could you give an example? Where did you take that @AppleNotOnBattery prefix from? Are there any others?



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: UMD on Aug 22, '03 03:48:23PM

i got that hint from the book "mac os x in a nutshell" page 299 (good book by the way). but unfortunatly the author does not explain where this prefix comes from or if there are any other prefixes like this one

the example is
10 * * * * @AppleNotOnBattery command

Hope this helps.



[ Reply to This | # ]
XJanitor.pl intelligently runs required maintenance tasks
Authored by: pmtav on Nov 02, '03 11:38:11PM

FYI that on 10.3, XJanitor seems to work fine with running the daily routines, but logs many lines of errors (Cannot find file: /usr/share/man/man3/DHparams_print.3ssl ... looks like 10.3 moved things around a bit) when running the weekly script (since my monthly routine had been run recently, I can't say what XJanitor does with the monthly routine)... looks like no harm done tho.



[ Reply to This | # ]