Scheduled jobs can be convenient to automate the maintenance or administration of a website application. You can create cron jobs per Container on your Cloud Container server.
You need a SSH/SFTP user linked to at least one Container to manage the scheduled jobs. If you use a SSH/SFTP user linked to a single Container you can follow these steps to add or edit your cron jobs:
containers/crontabs/
directory.crontab
file accordingly.You can use the command below to edit the file through an SSH session.
nano /container/crontabs/crontab
This crontab file uses the standard cron format and you can find more information about this on the Cron Wikipedia page. The Contrab Guru helper is handy if you would like to check your crontab set up.
For convenience, all Cloud Container servers have the base Operating System Time Zone set to UTC (0), consider this when configuring your scheduled jobs.
The jobs will be executed as the user www-data (uid: 33) on the Cloud Container servers. The www-data user should have access to all files and directories within the /container
directory but the /container/backup/containers
directory.
If your scheduled jobs are not working properly, the tips below can help you track down the issue:
MAILTO
variable, so you can receive the outputs of the command set when the task is processed. If no output is thrown, you won't receive emails./container/logs/rsyslog/syslog
log file. The lines as per the below indicate your crontab file is being processed.
CRON[XX]: (root) CMD (/bin/cat /cron/crontab | /usr/bin/crontab -u www-data -)
nano
or vim
text editors.In order to make the Cloud Containers as generic as possible, we had to make some choices and the mapping of the directory differs from what you can see in your SSH session. If you need to execute files under the application directory, or write some information into a log file, consider using /container/
instead of the paths you can see when connected via SSH.
Here is the matrix of the mapping from your ssh connection to the container:
Path to use | Equivalent path |
---|---|
/container/application | /data/docker_app |
/container/logs | /var/log/docker_app |
/container/config | /etc/docker_app |