mraza Posted March 31, 2011 Share Posted March 31, 2011 Hi, Is there any way i can use a php script to edit crontab jobs. i use this command on my centos based server to add/edit cronjobs. . "crontab -e" I wants to manage my cronjobs with a php file to add/edit cronjobs. Thans for any help. Quote Link to comment https://forums.phpfreaks.com/topic/232276-using-php-to-addedit-cronjobs/ Share on other sites More sharing options...
trq Posted March 31, 2011 Share Posted March 31, 2011 Of course. Look at the manual entry for crontab. man crontab Quote Link to comment https://forums.phpfreaks.com/topic/232276-using-php-to-addedit-cronjobs/#findComment-1194872 Share on other sites More sharing options...
mraza Posted March 31, 2011 Author Share Posted March 31, 2011 Thank you sir , i checked manual and i see this SYNOPSIS crontab [-u user] file so for example if i execute in my php script exec("crontab -u username -e cronjobfile.php"); will it use that cronjobfile.php to get cron jobs details? so i can add cronjobs to cronjobfile.php with my mysql db something, if you could show me a little bit of example i would really appreciate it sir. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/232276-using-php-to-addedit-cronjobs/#findComment-1194879 Share on other sites More sharing options...
mraza Posted March 31, 2011 Author Share Posted March 31, 2011 do i need to save that file as somename.txt ? so it contains lines of crontabs like * * * * /path/to/my/file/to/run * * * * /path/to/my/file/to/run and where i will store that file somename.txt Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/232276-using-php-to-addedit-cronjobs/#findComment-1195236 Share on other sites More sharing options...
mraza Posted April 5, 2011 Author Share Posted April 5, 2011 Hi, I have figured out how to add cron, i used exec("crontab -f cronfile.txt); Now i can see that cron is being added as apache user with this command: crontab -u apache -l Edit: fixed all thanks Quote Link to comment https://forums.phpfreaks.com/topic/232276-using-php-to-addedit-cronjobs/#findComment-1197356 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.