Dynadot .com transfer sale, only $10.12 with coupon code DYNA12, available while supplies last, ends October 31, 2026.

Cron

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

RLW

VIP Member
Impact
23
Hi,

I did a search and haven't been able to find an answer.

Can I set up a cron job to run every 5mins, but only between midnight and 2am every day?

I think the answer is no.

I need to run a script once a day, but it takes more than 30 seconds to run and dies before it finishes. The script fetches a number of rss feeds, does some processing on them and inserts some info into a database.

I've changed the script to process only a few feeds each time it runs, but it means I need to run the script about 23 times to process all the feeds.

I need all of the info as early in the day as possible. I could run the script/cronjob every hour, but that means that some of the feeds won't be processed until later in the day, making them useless.

If I run the cronjob every 5 mins then all the feeds will be processed nice and early in the day, but I'll be inundated with 288 confirmation emails a day, because the cronjob will keep running even though there aren't any feeds for it to process.

Any thoughts or questions?

Cheers,
Richard
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Around how many RSS feeds is it trying to process?
Also, what language is it written in?
 
0
Close
You can provide multiple values separated by commas:

This example will run every 5 minutes from midnight up to (but not including) 2 AM (and will not send you email)

0,5,10,15,20,25,30,35,40,45,50,55 0,1 * * * command > /dev/null 2>&1
 
Last edited:
1
Close
Around how many RSS feeds is it trying to process?
Also, what language is it written in?

About 600 feeds in total (I've broken it down into 23 feed chunks). PHP.

You can provide multiple values separated by commas:

This example will run every 5 minutes from midnight up to (but not including) 2 AM (and will not send you email)

0,5,10,15,20,25,30,35,40,45,50,55 0,1 * * * command > /dev/null 2>&1

Perfect... thanks!
 
0
Close
30 seconds must be the timeout for your scripts (PHP ?).
Have a look at the set_time_limit directive, if execution time can be overridden on your host.
 
0
Close
I think you need another cron to be involved - just to check if there are any new feeds. If there are - start the main script.
 
0
Close
Thanks for the response, Rob, but the feeds are updated constantly so they are always new.

I used enlytend's tip to make cron run like I wanted and it works perfect. I log everthing to a file, and when the last cron runs it sends me an email just so I can check everything was ok.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back