Hi, how can I use PHP to create cron jobs? I need to pass variables to a PHP script and execute the script at a specific point in time. I assume I need to use the exec() function. I would have to first type in the time and then the path to the PHP binary file and then the path to my script. My question is how can I pass variables to my PHP script and how can I delete the cron job? Or at least modify it via my PHP script.
I need to make a cronjob that is dynamic and specific to each user. If a user registers on my website today and makes payment today. It's November 2 2014. I want the person to pay me every month. So, I need to set the cronjob to execute my PHP file at December 2 2014. The PHP file will verify if the person made a payment and if not it will make changes in my database to set a boolean value to 0. If the person didn't make a payment I will send out an e-mail via my PHP script to give a reminder to make a payment. I will set another cronjob at the same time to delete the account. This will be set to one year from the date. So, in this case if the guy made a payment for only one month, then by next December of 2015, the person's account will be fully deleted. I want to set another cron job to run a PHP script just to e-mail the person 14 days from the expiration date as a reminder.
However, I need to either delete or modify the cronjob each month such that my PHP script will check if a payment was made. If this is true then I would need to modify the cronjob to set it for a month after.
For example:
November 2 2014, we as a customer paid for one month for our account that we created. A cronjob will set my special PHP file to execute on December 2 2014.
So, now December 2 2014 comes and runs my script. My script looks up in the database that I made payment for the second month. So, now my script needs to change the cronjob to execute the same script again next month. In this case it's January 2 2015.
Now, notice that these dates and times are specific to the user. I want to give the person an actual month of services. So, I cannot set the scripts to go off at either the first of the month or the last day of the month. I track and store payment information and date and time information when they made payment and when it's due.
So, I need to make something that is dynamic that will create cronjobs on the fly for each user. I do need to pass the user's name to the script so the script can make the changes to the right person's account.
I was told I need to use PHP's argv array which stores the file name and arguments passed to it in this array. I am not to use the GET or POST arrays.
I need resources to figure out how to do this.
I need to make a cronjob that is dynamic and specific to each user. If a user registers on my website today and makes payment today. It's November 2 2014. I want the person to pay me every month. So, I need to set the cronjob to execute my PHP file at December 2 2014. The PHP file will verify if the person made a payment and if not it will make changes in my database to set a boolean value to 0. If the person didn't make a payment I will send out an e-mail via my PHP script to give a reminder to make a payment. I will set another cronjob at the same time to delete the account. This will be set to one year from the date. So, in this case if the guy made a payment for only one month, then by next December of 2015, the person's account will be fully deleted. I want to set another cron job to run a PHP script just to e-mail the person 14 days from the expiration date as a reminder.
However, I need to either delete or modify the cronjob each month such that my PHP script will check if a payment was made. If this is true then I would need to modify the cronjob to set it for a month after.
For example:
November 2 2014, we as a customer paid for one month for our account that we created. A cronjob will set my special PHP file to execute on December 2 2014.
So, now December 2 2014 comes and runs my script. My script looks up in the database that I made payment for the second month. So, now my script needs to change the cronjob to execute the same script again next month. In this case it's January 2 2015.
Now, notice that these dates and times are specific to the user. I want to give the person an actual month of services. So, I cannot set the scripts to go off at either the first of the month or the last day of the month. I track and store payment information and date and time information when they made payment and when it's due.
So, I need to make something that is dynamic that will create cronjobs on the fly for each user. I do need to pass the user's name to the script so the script can make the changes to the right person's account.
I was told I need to use PHP's argv array which stores the file name and arguments passed to it in this array. I am not to use the GET or POST arrays.
I need resources to figure out how to do this.
Last edited by a moderator: