You can define scheduled jobs that explicitly trigger specific actions using Drush.
When attempting this, keep in mind the following:
--root=/var/www/html/${AH_SITE_NAME}/docroot argument, or use a Drush site alias, or prefix your command with a cd that switches to the correct folder.cd $HOME to switch to your home folder before running it to ensure it will run within the scheduled job’s available environment.You can create scheduled jobs to run shell scripts you have written.
The following example assumes you have added scripts/my-script.sh to your repository:
/var/www/html/${AH_SITE_NAME}/scripts/my-script.shWhen a scheduled job runs and the output does not redirect to stdout, the cron user sends an email to the application user on the same infrastructure.
Cloud Platform stores output logs, PHP error logs, and Drupal watchdog logs in the cloud. To access these logs, use API calls or the Cloud Platform user interface. For more information, refer to About Cloud Platform logging.
Scheduled cron jobs logs: Use cron job logs to access all output including stdout, stderr, and PHP errors.
Drupal watchdog logs: Drupal watchdog records the logs individually. Access these records through the Drupal watchdog log download.
PHP error logs
To record logs in persistent storage, redirect the output to a file such as the following example. This method is not recommended because it consumes disk quota. If you redirect the output, you must implement automatic log truncation.
drush --uri=http://[site-uri] -d -v cron &>> /shared/logs/drush-cron.logIn the previously mentioned example, &>> /shared/logs/drush-cron.log logs the cron output to a drush-cron.log file in the logs directory of the infrastructure.
To improve usability, add a timestamp to the log messages. Replace [site-uri] with the base URL of the website where you must run cron.
drush --uri=http://[site-uri] -d -v cron 2>&1 | awk '{print "["strftime("%Y-%m-%d %H:%M:%S %Z")"] "$0}' &>> /shared/logs/drush-cron.logLog files must not exceed 1 GB in size. Therefore, you must periodically prune outdated logs. Log files do not rotate.
Cloud Platform saves the email in /var/mail. If the messages are never picked up or cleared, the messages fill the disk. This might cause issues, including bringing down your application.
To avoid issues, you must include a logging statement in scheduled jobs. For example, you can use the following statement by replacing [site-uri] with the base URL to the website where you want to run cron:
drush --uri=http://[site-uri] -d -v cron &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-cron.logIn the preceding example, &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-cron.log logs the cron output to a drush-cron.log file in the infrastructure’s logs directory. The output log file is rotated along with the other logs in the logs directory. This log file is rotated only if the file is named drush-cron.log. For more information, see About Cloud Platform logging.
To improve usability, you can add a timestamp to the log messages. For example, you can replace [site-uri] with the base URL to the website where you want to run cron.
drush --uri=http://[site-uri] -d -v cron 2>&1 | awk '{print "["strftime("%Y-%m-%d %H:%M:%S %Z")"] "$0}' &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-cron.logYou must run this command as a standalone script as it exceeds the 255 character limit for scheduled jobs.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
To record logs in persistent storage, redirect the output to a file such as the following example. This method is not recommended because it consumes disk quota. If you redirect the output, you must implement automatic log truncation.
drush --uri=http://[site-uri] -d -v cron &>> /shared/logs/drush-cron.logIn the previously mentioned example, &>> /shared/logs/drush-cron.log logs the cron output to a drush-cron.log file in the logs directory of the infrastructure.
To improve usability, add a timestamp to the log messages. Replace [site-uri] with the base URL of the website where you must run cron.
drush --uri=http://[site-uri] -d -v cron 2>&1 | awk '{print "["strftime("%Y-%m-%d %H:%M:%S %Z")"] "$0}' &>> /shared/logs/drush-cron.logLog files must not exceed 1 GB in size. Therefore, you must periodically prune outdated logs. Log files do not rotate.
Cloud Platform saves the email in /var/mail. If the messages are never picked up or cleared, the messages fill the disk. This might cause issues, including bringing down your application.
To avoid issues, you must include a logging statement in scheduled jobs. For example, you can use the following statement by replacing [site-uri] with the base URL to the website where you want to run cron:
drush --uri=http://[site-uri] -d -v cron &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-cron.logIn the preceding example, &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-cron.log logs the cron output to a drush-cron.log file in the infrastructure’s logs directory. The output log file is rotated along with the other logs in the logs directory. This log file is rotated only if the file is named drush-cron.log. For more information, see About Cloud Platform logging.
To improve usability, you can add a timestamp to the log messages. For example, you can replace [site-uri] with the base URL to the website where you want to run cron.
drush --uri=http://[site-uri] -d -v cron 2>&1 | awk '{print "["strftime("%Y-%m-%d %H:%M:%S %Z")"] "$0}' &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-cron.logYou must run this command as a standalone script as it exceeds the 255 character limit for scheduled jobs.
If this content did not answer your questions, try searching or contacting our support team for further assistance.