how to set up a cron job

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

how to set up a cron job

Post by Charles256 »

erm.can't seem to search properly:-/ How do you set up a cron job if there isn't an option on my vdeck?is there any way to code one?if so where? i'm on a shaerd server.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Shell access will do it. :roll: But you probably don't have that. Call support. That's what I would do...
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Sometimes your account control panel can give you access to cron. If you have to get support to set it up, I'd suggest you ask them to just make a cron job for a control file of yours. You can then use that control file to call other files depending on the time. That way, if you want to add more cron jobs, you just modify the control file, rather than talking to support again.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

control file you say? and how is a control file structured? I've never used a cron before, I'm wanting to do some research into how crons work and I find hands on experience works best,hence my original question. :)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

"Control File" was just my terminology. There's no sense me going further into what I meant unless you need to talk to support to get your cron job going.

Do you have shell access?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

nopers :-/
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If you don't have shell access, then you've really only got two options.

The first option is to talk to support and see if they can set up a cron job for you. If you do this, then I'm back to suggesting you use (what I called) a control file. What I'd suggest is get support to run your file (say: example.php) every 10 minutes. Then, in example.php, you check the time and depending on the actual time, you run particular files - essentially your own copy of cron.

The second option is to tie in whatever you want cronned into the template of your website (if this isn't for a website, this might not work). So, you could just run whatever you wanted cronned, on the first page load of the hour. This'll make the first page load a bit slower, and won't guarantee you get your stuff done every hour on the hour, but you might not have a choice if support can't/won't set up a cron job for you.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

i like that first option.i'll call support when i get home,thanks.
Post Reply