shell_exec and cron!

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
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

shell_exec and cron!

Post by Joe »

If I had a file named cron.php which executed a command would it be possible to set this as a cronjob using a PHP command such as shell_exec()?

Joe 8)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You mean use shell_exec() to set a crontab? I believe that'd all depend on the permissions your php has.. I'd think no.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Hmm, I noticed that Cpanel etc allows you to set cronjobs, how is this possible without the use of a shell?.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

cpanel has more access rights than your php install..
ast3r3x
Forum Commoner
Posts: 95
Joined: Thu Aug 19, 2004 8:36 pm

Post by ast3r3x »

Because you are probably trying to do something similar to me, I'll ask my question here.

I want a script to run daily that sends out an email to delinquent accounts. I was wondering if there is a way to do with even if the server is not accessed that day. I think cron jobs are out of the question because it's not a dedicated server.

I guess I could tell the guy he has to at least visit the site everyday, but thats such an inelegant solution.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

There is directories within home/etc such as cron.daily, cron.weekly etc. You can create files within these directories and they will run at the specified time. The only problem is permission errors. Trying something like:

Code: Select all

chmod -R 0777 /home/etc/cron.daily
via ssh fails to work. :(
Post Reply