Skip to main content

Run a cron job which running time is decided by another PHP page

Comments

3 comments

  • cPanelMichael
    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
  • red whale
    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
  • linux4me2
    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.