Run a cron job which running time is decided by another PHP page
cPanel provides the cron job setting interface. You can add the time you'd want to run the command. However, you can just only add the unvaried value of time and cannot make it flexible (Such as make the running time decided by another PHP page) So how can I use cPanel to add a flexible time?
P.S. I can't use exec or system function to achieve it, because the server administrator doesn't allow me to use these two functions due to the security reasons. The only way I can do is to add the cron job time via the cPanel.
-
Hello :) Could you provide a specific example of how you want flexible time implemented? For instance, do you want the time the cron job runs to automatically change based on certain variables? If so, you may need to build that functionality into the custom script itself. Thank you. 0 -
Hello :) Could you provide a specific example of how you want flexible time implemented? For instance, do you want the time the cron job runs to automatically change based on certain variables? If so, you may need to build that functionality into the custom script itself. Thank you.
Hello Thanks for your response I hope the running time of the cron job can be decided by another PHP script which is on my website. For example, I can let the user inputs the time on the form whenever they want. After submitting the form, create a cron job which running time is based on the form the user has filled. Suppose the user input the time "37 1 20 12 0" and the target "/home/username/public_html/mail.php". After submitting the data, sending a mail on 12/20 at 1:37 automatically. The point confuse me is that "how to build that functionality into the custom script itself?" I can't use exec and system function in PHP and that's why I need to create the cron job(s) only via cPanel. But cPanel can only add the unvaried running time manually. So that's is the problem I want to solve. Thank you.0 -
You could create a database to hold all the mail times saved by your users. When your users submit the form with the time and other data, you save it to the database. Set up a cron job through cPanel that runs a PHP script that checks the database for any emails that are due to be sent, and sends those that are due. You can run the cron job linked to your PHP script as frequently as you need to--even every minute if your web host allows it--to execute the script and send the emails. 0
Please sign in to leave a comment.
Comments
3 comments