How to create a cron job from php from virtual server

Hi!

We need to have php to setup cronjob for us. I've read that it's possible to do it.

Can you point us to requirment and how to achieve it from a virtual server account?

Thanks in advance for your help!

Status: 
Active

Comments

Do you mean create a cron job from a PHP script? This may be possible, if the cron job runs as the domain's user ... however, there is no real API for this. Instead your script would need to somehow call the crontab command.

Yes i mean by a php script.

My programmer asked me about it. He's thinking that some server restriction make it to dont work simply. He tried in few ways but didt get it to work.

If you have some clues about how to achieve it, it will be appreciate. If not, i will ask him to digg more deeper about it.

Thanks!

From the command line it's working. It isnt from php, that's the reason why.

You may want to verify that in Server Configuration -> Website Options, that your domain is configured to use either FCGID or CGI.

If it's using mod_php, that may indeed be a problem, as mod_php runs as the Apache user, not as the Virtual Server owner. The Apache user doesn't have rights to create cron entries for your Virtual Server owner.

It's running FCGId

Yeah that should be possible then. It sounds like you're likely to be seeing an issue with the particular PHP script. So long as the PHP app is running as the Virtual Server, it should be able to work, there's nothing preventing it from adding, modifying, and deleting cron jobs for that user.

Ok, i will advise my programmer about it.

Thanks again for your support!