PDA

View Full Version : Cron jobs not running


bshubinsky
12-16-2009, 11:05 AM
Not sure if this is the right forum or not, but I figured it was since it's more cron related than anything.

I have an account that runs in Simple Finder mode. I've made an AppleScript that deletes all items from the desktop and documents folder. I then made a crontab to have that cron run every five minutes - this is my script:

*/5 * * * * '/Volumes/HD/DeleteDocs.app'

I can run the script fine manually, but it never seems that the cron job actually runs. Anyone have any ideas?

tlarkin
12-16-2009, 11:53 AM
You may want to look into having launchd run those jobs

bshubinsky
12-16-2009, 11:56 AM
I'm not super familiar with launchd (and apparently neither am I with cron it seems). Plus we're on 10.3, I thought launchd only worked with 10.4+

Hal Itosis
12-16-2009, 12:23 PM
It may be that you need to target the executable inside the app:
/Volumes/HD/DeleteDocs.app/Contents/MacOS/DeleteDocs

[but i agree that launchd is the better way to go]

tw
12-16-2009, 02:10 PM
you do want to look into having launchd run this. if nothing else, you can set it up as a watchfolder plist that will only be invoked when someone adds something to the folders (obviating the need to run it every five minutes). looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>my.kill.cruft</string>
<key>ProgramArguments</key>
<array>
<string>open</string>
<string>-a</string>
<string>/Volumes/HD/DeleteDocs.app</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/username/Desktop</string>
<string>/Users/username/Documents</string>
</array>
</dict>
</plist>
it might load quicker if you save it as a compiled script (.scpt) and run it from osascript. that would be:
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Volumes/HD/DeleteDocs.scpt</string>
</array>

Hal Itosis
12-16-2009, 02:41 PM
Ah, AppleScript... i missed that part. (So the path in my post is not quite right... i guess "applet" is the main executable).

Wouldn't it be ironic if this AppleScript contains a bunch of 'do shell script' calls? It would probably be simpler to do that sort of house-cleaning-type cron job in a shell script to begin with (and just skip the AppleScript middleman).

tlarkin
12-16-2009, 02:48 PM
Ah, AppleScript... i missed that part. (So the path in my post is not quite right... i guess "applet" is the main executable).

Wouldn't it be ironic if this AppleScript contains a bunch of 'do shell script' calls? It would probably be simpler to do that sort of house-cleaning-type cron job in a shell script to begin with (and just skip the AppleScript middleman).

Unless you wanted some sort of GUI actions to happen with it.

Hal Itosis
12-16-2009, 03:03 PM
Unless you wanted some sort of GUI actions to happen with it.

Every 5 minutes? :eek:
Yeah, maybe. ;)

tlarkin
12-16-2009, 03:05 PM
Every 5 minutes? :eek:
Yeah, maybe. ;)

Hey, there are such things as pranks....I set a script to run the say command on a co-workers computer every 15 minutes