John Davidson

php - Run silverstripe SS4 tasks as cron jobs in a subdomain of SS3


I have a CPanel account. I have a main site still in SS3 and an SS4 copy of the site. The SS4 is still being developed/tested. The SS4 site is a subdomain, as in

I am trying to run Silverstripe tasks as cron jobs.

The first, for SS3, goes
php public_html/framework/cli-script.php dev/tasks/ReadCSV > public_html/results.html

where “results.html” is just a log file. It works.

My problem is that I’d like to run something similar for SS4.

php public_html/com4/vendor/silverstripe/framework/cli-script.php dev/tasks/PCWLoadRecords > public_html/com4/pcwresults.html

When I run the task in the browser, it works.

When I run it as a cron job, I get a 500 error in the log file.

When I run it manually in Terminal, I get an empty output.

I’ve also tried going into the subdomain (via Terminal) and, at the document root for the SS4 site typing
vendor/silverstripe/framework/sake dev/tasks/PCWLoadRecords > afile.txt

but I still get an empty output file.

I suspect cli-script.php doesn’t know which tasks to look at (SS3 or SS4) but I really have no idea.

I’ve set SS_BASE_URL to “”

Anything else I can do?

My Answer:
The second, for SS4, would be similar but with the path to the SS4 installation. Assuming your SS4 installation is in a folder called "ss4" within the public_html directory, the command would be:

php public_html/ss4/framework/cli-script.php dev/tasks/YourTaskName

Replace "YourTaskName" with the actual name of the task you want to run. You can also add any additional parameters required by the task after the task name.

You can set up a cron job in CPanel to run this command at regular intervals. Just log in to your CPanel account, find the Cron Jobs section, and add a new cron job with the command above. Set the frequency and timing for the cron job as needed.

Make sure to test the command manually first to ensure it runs correctly before setting it up as a cron job.

Rate this post

3 of 5 based on 2398 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us