blueman378 Posted November 27, 2008 Share Posted November 27, 2008 Hi guys ive done some googling but haved come up blank, is ther any way to programatically setup a cron job through php? Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/ Share on other sites More sharing options...
blueman378 Posted November 27, 2008 Author Share Posted November 27, 2008 hmm im looking at pseudo cron and its looking a whole lot more reliable for on a commonly distributed application than cron, only problem is its a request based thing, still as long as i don't need anything to happen before a user views the site it seems fine. if its just for trimming databases can anyone see a better solution? Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/#findComment-700348 Share on other sites More sharing options...
laffin Posted November 27, 2008 Share Posted November 27, 2008 see if ya have access exec(). if ya do than ya can pull yer cron info, using crontab. Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/#findComment-700352 Share on other sites More sharing options...
o3d Posted November 27, 2008 Share Posted November 27, 2008 I'm replying from a debian perspective. The problem isn't the exec function, the issue is apache is running as user www-data. It is not wise to execute scripts through apache as root on a production box. What I eventually did was to create a text file (as www-data) containing the cron contents and place it in a non-web-accessible folder. I wrote a php script which is executed by cron every minute to read the contents of the folder for any new 'cron' files. When a file is found, change the owner to root and move the file to /etc/cron.d/ That works for me. Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/#findComment-700360 Share on other sites More sharing options...
blueman378 Posted November 28, 2008 Author Share Posted November 28, 2008 hmm sorry guys i dont think i made myself all that clear. im developing something which will be used on servers where people are not admins, eg a general hosting account and most free accounts dont allow cron do they? Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/#findComment-700828 Share on other sites More sharing options...
laffin Posted November 28, 2008 Share Posted November 28, 2008 if ya have access to cpanel, ya shud have access to cron thru cpanel interface. if ya have that, ya can setup a php script to post current crons and check another file for any updates than as e3d said, ya have a web interface, which checks current crons as well as post the updates... actually sounds like a fun project. but if ya dun have access to cronjobs, ya wud have to go with a pseudo type cron, which is run on page loads instea, it works, but it wont run at the exact time. on popular sites, this system isnt bad, but on low hit sites, it can be awhile before it updates. Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/#findComment-700895 Share on other sites More sharing options...
blueman378 Posted November 28, 2008 Author Share Posted November 28, 2008 yeah im building a forum system and basically i was thinking of using cron to clean the active users, but i guess no real need considering the table size isnt going to change if no user logs in lol and the stats would be viewed by the user. hence updating the page Quote Link to comment https://forums.phpfreaks.com/topic/134503-setting-up-a-cronjob-through-php/#findComment-700920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.