Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-22-2011, 02:11 PM   #1
AzteK
Confirmed User
 
AzteK's Avatar
 
Industry Role:
Join Date: Feb 2001
Location: Northern Cali, USA
Posts: 3,444
CRON Question

How can I run cron on the 1st hr, 2nd hr, 4th hr...in a 24 hour period, everyday, every month, every year?
AzteK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 02:32 PM   #2
signupdamnit
Confirmed User
 
signupdamnit's Avatar
 
Industry Role:
Join Date: Aug 2007
Posts: 6,697
http://en.wikipedia.org/wiki/Cron

Generally by using @hourly or "0 * * * *" in your crontab file.

The "0" says "every time the minute is :00" which of course works out to hourly. But if you want to run it 30 minutes past the hour every hour you might do "30 * * * *", for example.

See the wiki article for more details.

Last edited by signupdamnit; 02-22-2011 at 02:33 PM..
signupdamnit is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 02:42 PM   #3
AzteK
Confirmed User
 
AzteK's Avatar
 
Industry Role:
Join Date: Feb 2001
Location: Northern Cali, USA
Posts: 3,444
I found my answer there!!

0 */2 * * * /home/user/jim/test.pl
0 */3 * * * /home/user/jim/test.pl
0 */4 * * * /home/user/jim/test.pl

Thanks!!
AzteK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 02:46 PM   #4
signupdamnit
Confirmed User
 
signupdamnit's Avatar
 
Industry Role:
Join Date: Aug 2007
Posts: 6,697
Oh that's what you wanted?

Just to make sure it is:

Quote:
Originally Posted by AzteK View Post
I found my answer there!!

0 */2 * * * /home/user/jim/test.pl
Means every other hour.

Quote:
0 */3 * * * /home/user/jim/test.pl
Every 3 hours.

Quote:
0 */4 * * * /home/user/jim/test.pl
Every 4 hours.
signupdamnit is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 03:08 PM   #5
AzteK
Confirmed User
 
AzteK's Avatar
 
Industry Role:
Join Date: Feb 2001
Location: Northern Cali, USA
Posts: 3,444
The following line causes the user program test.pl – possibly a Perl script – to be run every two hours, namely at midnight, 2am, 4am, 6am, 8am, and so on:

0 */2 * * * /home/user/jim/test.pl


oh no I guess it's not what I wanted... :L

I need it to run like this:

1:00 /home/user/jim/test.pl
2:00 /home/user/jim/test2.pl
3:00 /home/user/jim/test3.pl
4:00 /home/user/jim/test4.pl

and so forth

Last edited by AzteK; 02-22-2011 at 03:10 PM..
AzteK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 03:16 PM   #6
AzteK
Confirmed User
 
AzteK's Avatar
 
Industry Role:
Join Date: Feb 2001
Location: Northern Cali, USA
Posts: 3,444
so would it be like this?

0 0/1 * * * /home/user/jim/test.pl
0 0/2 * * * /home/user/jim/test2.pl
0 0/3 * * * /home/user/jim/test3.pl
AzteK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 06:07 PM   #7
signupdamnit
Confirmed User
 
signupdamnit's Avatar
 
Industry Role:
Join Date: Aug 2007
Posts: 6,697
Quote:
oh no I guess it's not what I wanted... :L

I need it to run like this:

1:00 /home/user/jim/test.pl
2:00 /home/user/jim/test2.pl
3:00 /home/user/jim/test3.pl
4:00 /home/user/jim/test4.pl

and so forth
Quote:
Originally Posted by AzteK View Post
so would it be like this?

0 0/1 * * * /home/user/jim/test.pl
0 0/2 * * * /home/user/jim/test2.pl
0 0/3 * * * /home/user/jim/test3.pl
Just three different scripts then? There are different ways to go but in a pinch perhaps this might work:

0 1 * * * /home/user/jim/test.pl
0 2 * * * /home/user/jim/test2.pl
0 3 * * * /home/user/jim/test3.pl
0 4 * * * /home/user/jim/test.pl
0 5 * * * /home/user/jim/test2.pl

and so on.

In this example:

test.pl would run at 1am and 4am.
test2.pl would run at 2am and 5am
test3.pl would run at 3am.

Another way of doing the above (same thing) would be:

0 1,4 * * * /home/user/jim/test.pl
0 2,5 * * * /home/user/jim/test2.pl
0 3 * * * /home/user/jim/test3.pl

... but there are all sorts of ways to do it.

You'll probably want to redirect the output in some way too.

Also see this: http://www.tutorial5.com/content/view/95/51/
It's a decent tutorial which may be of some help.

You can type 'man crontab' at the command line to see the man page as well.

Last edited by signupdamnit; 02-22-2011 at 06:09 PM..
signupdamnit is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 06:18 PM   #8
signupdamnit
Confirmed User
 
signupdamnit's Avatar
 
Industry Role:
Join Date: Aug 2007
Posts: 6,697
And to make it more clear if you were just wanting a different script for each hour of the day I guess you could do something like:

0 1 * * * /home/user/jim/test.pl >/dev/null 2>&1
0 2 * * * /home/user/jim/test2.pl >/dev/null 2>&1
0 3 * * * /home/user/jim/test3.pl >/dev/null 2>&1

...

0 23 * * * /home/user/jim/test23.pl >/dev/null 2>&1

The ">/dev/null 2>&1" at the end says to discard the output so that it doesn't email it to you for each hour.

Hope this helps.
signupdamnit is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-22-2011, 06:53 PM   #9
AzteK
Confirmed User
 
AzteK's Avatar
 
Industry Role:
Join Date: Feb 2001
Location: Northern Cali, USA
Posts: 3,444
Quote:
Originally Posted by signupdamnit View Post
And to make it more clear if you were just wanting a different script for each hour of the day I guess you could do something like:

0 1 * * * /home/user/jim/test.pl >/dev/null 2>&1
0 2 * * * /home/user/jim/test2.pl >/dev/null 2>&1
0 3 * * * /home/user/jim/test3.pl >/dev/null 2>&1

...

0 23 * * * /home/user/jim/test23.pl >/dev/null 2>&1

The ">/dev/null 2>&1" at the end says to discard the output so that it doesn't email it to you for each hour.

Hope this helps.
That's exactly what I want it to do, to run different scripts every hour of the day. I'll give it a shot. Thank you!
AzteK is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.