PHP exec(), executing a php script, how do do that?
Posted on 2011-03-02
I was wondering how to execute a php file with php exec() without waiting for any response. I have too many cron jobs. Instead of going to server and adding them manually, I would like to add just 1 file let's call it cron_jobs.php. Of course I am going to have other php scripts like check_status_bot.php, check_files_bot.php.
I can call any information from database related to bots which ones are going to executed and when, if conditions are matched.
I can do the rest very easily but I never tried such function like exec() before. What I need with exec() function are;
1. Shouldn't wait for response after executing script (such as if it was successful or not). If it is possible, log the responses to a log file.
2. I am not sure if it is already a feature of exec function or not, I would like to run the files under php / apache or another user. My problem here is if I try to execute a php file which is going to take long time to finish, it shouldn't make my cron_jobs.php file busy, it will just execute, while other script is being executed, cron_jobs.php should process rest of the codes.
3. Is it secure to use? Could this function create any security holes?
I'm sorry for my english, I might make some mistakes. I just hope, I was able to describe clearly what I really want to achieve. I will be really glad if anyone could help me out with this barrier to continue my project and make my life easier.