Can I setup cron jobs?

RSS

Can I setup cron jobs?

Last updated February 9th, 2016

Of course it is possible for you to create cron jobs on your Cloud Container server. To be more specific, you can create cron jobs per container.

What are the pre-requisites?

First you need to make sure you have added a SSH/SFTP user and linked it to your container.

Where do I add my jobs?

You must SSH into to your server and navigate to the "crontabs" directory of the desired container. More information about the directory structure of containers can be found here.

Inside this directory you will find a file called "crontab", this is where you need add your jobs. This file uses the standard cron format and you can find more information about this on the Cron Wikipedia page.

Which user will execute my job?

The jobs will always be executed as the user www-data (uid: 33). The crontab inside the container is stored under /var/spool/cron/crontabs/www-data.

How long will it take for my job to start running?

Expect a delay of about one minute when you edit and save the file before it gets applied on the container.

What about the filesystem inside the container?

If you need to execute files under the application directory, or write some information into a log file you might be tempted to specify the same path you can see when connected via SSH.

Unfortunately to make our product 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.

Here is the matrix of the mapping from your ssh connection to the container:

* ~/containers/CONTAINER_NAME/application -> /data/docker_app
* ~/containers/CONTAINER_NAME/logs        -> /var/log/docker_app
* ~/containers/CONTAINER_NAME/config      -> /etc/docker_app

Example:

Here we want to execute a script which runs every five minutes at the root of our container and logs information:

*/5 * * * * php /data/docker_app/public/export.php &> /var/log/docker_app/cron_export.log
Can we improve this article? Suggest an improvement to this article.

Suggest an Improvement

Thank you for helping us to improve this Knowledge Base article. Please type your suggestions below:

Still need help? Get in touch with us.

If you aren't able to find the help you need then please send us a question and we can help you further.