i\'m trying to run a php script using the heroku scheduler. What command should i put in after the $ in heroku. I keep getting file not found. I have transferred the file i want
How to run a PHP script with Heroku Scheduler?
With a directory structure and Procfile
looking something like this:
├─ Procfile
├─ web/
├── (your webfiles)
├─ worker/
└── myscript.php
Procfile
:
web: vendor/bin/heroku-php-apache2 web/
worker: php worker/myscript.php
Then you can test your worker from the command-line like so:
heroku run worker
To schedule a job, go into Heroku Scheduler and add the job in a similar fashion, but without the heroku run
segment (else you'll get bash: heroku: command not found
errors), just:
worker
Or, alternatively, directly:
php worker/myscript.php
You can see the job in the app's logs. e.g.:
2017-09-01T14:19:37.397210+00:00 heroku[scheduler.9540]: Starting process with command `php worker/myscript.php`
worker
name in the Procfile
could be set to something else. e.g.: myworker
, mysuperduperscript
, etc.web
section, but it's optional if all you want is a worker / background service and don't need to serve files on the web.Alternative: if, for whatever reason, you'd rather perform a GET/POST request on a URL, you can use the Temporize Scheduler add-on.