Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mufflon

macrumors 6502
Original poster
Sep 15, 2006
264
2
I must confess I'm not the most well versed when it comes to reoccuring events, especially those that i don't have to attend to every waking hour :)
I have made a small imap php script to gather news to a site I'm developing on my spare time, but I don't know what to do :confused:

Ideally the script should do:
1) open any kind of browser
2) go to site
3) close browser

every one hour

the hardware I'm using is 10.4 server edition, though i'm not sure it matters

I have sought high and low with rather crappy results, I might have looked in the wrong locations, but definetly not found anything.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
Ideally the script should do:
1) open any kind of browser
2) go to site
3) close browser
If it's something that just needs to run on your own machine, it sounds like a perfect job for AppleScript (although maybe I don't understand everything you're trying to do). You could also set up a cron event to fire it off every hour, or just have it run in the background continuously and activate once per hour.
 

mufflon

macrumors 6502
Original poster
Sep 15, 2006
264
2
Sigh and here I was trying to teach myself cron from random sites while applescript beckoned with simplicity. Tnx for the help though :)

The script I made:

Code:
repeat with shotcount from 1 to 1000
	tell application "Safari"
		activate
		set the URL of document 1 to "myURL"
	end tell
	delay (60 * 60 * 3)
end repeat

I reckon I can accept restarting the script once every 3000th hour or so =)
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
I reckon I can accept restarting the script once every 3000th hour or so =)
Just make it an endless loop and put it in System Preferences > Accounts > Login Items and you won't ever have to touch it. I think there's a way to make AppleScripts run without showing up in the dock or command-tab view but I don't know how.
 

MongoTheGeek

macrumors 68040
Sigh and here I was trying to teach myself cron from random sites while applescript beckoned with simplicity. Tnx for the help though :)

The script I made:

Code:
repeat with shotcount from 1 to 1000
	tell application "Safari"
		activate
		set the URL of document 1 to "myURL"
	end tell
	delay (60 * 60 * 3)
end repeat

I reckon I can accept restarting the script once every 3000th hour or so =)

Try this. It will bog the system far less

Code:
on idle
	tell application "Safari"
		activate
		set the URL of document 1 to "myURL"
	end tell
	return 3*hours
end idle

save it as a stay up application.

if you really feel the need to use repeat and delay

Code:
repeat
	tell application "Safari"
		activate
		set the URL of document 1 to "myURL"
	end tell
	delay (60 * 60 * 3)--this works but 3*hours is easier to read
end repeat
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.