How to pass parameters to file path? This is what I’m trying to do:
*/2 * * * * /usr/bin/php /var/www/mysite/public_html/cron/cron.php?group=3 >> /var/www/mysite/public_html/cron/cron.log 2>&1
I also tried without the question mark ‘?’ but the cron does not run.
*/2 * * * * /usr/bin/php /var/www/mysite/public_html/cron/cron.php?group=3 >> /var/www/mysite/public_html/cron/cron.log 2>&1
To to pass the parameter?
Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Generally you would not use this method to pass parameters to a CLI PHP script. Instead you would do something like:
*/2 * * * * /usr/bin/php /var/www/mysite/public_html/cron/cron.php 3 >> /var/www/mysite/public_html/cron/cron.log 2>&1
Using $argv[0] to get the value inside your script.
As the file is inside the public_html directory you can also use curl to issue a HTTP request via URL:
*/2 * * * * curl -s http://example.com/cron/cron.php?group=3 >> /var/www/mysite/public_html/cron/cron.log 2>&1
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.