Configuring cron: Expired content and sitemap update
2 October 2023 | Documentation v2
From version 2.0.6, Tuskfish gained the ability to set an expiry date for content, and to automatically update the site map file. This is managed by a daily cron job, which runs the script trust_path/cron/expiresOn.php at midnight each day.
To enable the service you need to add a daily cron job to the server, ideally running at midnight. In managed hosting environments (cPanel etc) there will be a crontab section in the dashboard / GUI, but if you are managing your own server you need to edit the crontab manually. You can open the crontab with the command:
Then add the following entry, editing the paths to the PHP binary and expiresOn.php script to match your local environment:
0 0 * * * /usr/local/bin/php /var/www/trust_path/cron/expiresOn.php
To check that it works, you can add a piece of content and set the expiry date for yesterday. At midnight, it should be automatically marked offline and the cache rebuilt. Alternatively, you can just check the timestamp on sitemap.txt the following day, to ensure that it was updated at midnight.
If you are using Tuskfish inside a Docker container (which may not have a crontab), you can use the host machine's crontab to run the job, via Docker's exec command:
0 0 * * * docker exec -t container-name /usr/bin/local/php /var/www/somepath/cron/expiresOn.php
Note that this command must not use the interactive flag -i, because it not being run in an interactive context.
Copyright, all rights reserved.