With Copilot
Acquia Copilot is a conversational AI connected into our product documentation and knowledge base. Ask Copilot about product features, technical details, troubleshooting and how to get started with Acquia products.
Sign in to use Acquia Copilot
On Cloud Platform environments, advanced custom tasks can be scheduled using the scheduled jobs feature or triggered through Drush cron.
When creating custom scheduled jobs, the following limitations apply:
% character is a special character in cron commands. If your command uses this special character, be sure to precede it with a backslash (\). For example: your_log_file_$(date +\%F).log.The maximum duration of code deploy tasks is 1 hour. Exceeding this time will stop the task, and the original code will remain.
If you find your scheduled jobs failing to complete, try defining them to use Drush cron instead of the Acquia cron-wrapper.sh script to take advantage of the greater memory limit available to CLI commands. For related information, see Debugging cron.
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.sh
When 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 the logs in /shared/logs. 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 &>> /shared/logs/drush-cron.logIn the preceding example, &>> /shared/logs/drush-cron.log logs the cron output to a drush-cron.log file in the infrastructure’s logs directory.
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}' &>> /shared/logs/drush-cron.logThe size of your log files must not exceed 1 GB. Therefore, you must periodically prune outdated logs. Unlike Cloud Classic, log files are not auto-rotated in Cloud Next.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
If this content did not answer your questions, try searching or contacting our support team for further assistance.