How to add a task to Cron on the server?

Adding Cron to a server is not a difficult task, even though it requires using a terminal and logging in to the server via SSH. This tutorial will show you how to easily add cyclic tasks to a server.

What's the cron syntax?

Crones are saved in the following format, for example: */10 * * * *  /usr/bin/curl "https://thecamels.org/wp-cron.php >/dev/null 2>&1

A task has two parts, a rule when the task is to be executed (asterisks) and a command to be executed.

The asterisks mark the time, in order: minutes (0-59), hours (0-23), days of the month (1-31), months (1-12), days of the week (0-6) - with this notation you can set any condition when the task should be executed.

It may seem complicated, but you don't have to learn it at all. Using that tool, you can easily program the time of your task.

Adding a task to Cron

  1. Log in to the server.
  2. Enter the following command in the terminal: crontab -e
  3. You're in a word processor now. Press i, now in the bottom left corner of the terminal you will see - - INSERT - -, you are in text input mode.
  4. Enter/paste the task to be executed, as described in the previous paragraph.
  5. When you think that the task is wrote correctly, press the Esc key and then :x to save the changes.
  6. When you exit the editor you will see crontab: installing new crontab is a sign that the task has been added correctly.
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to set SSH tunel

Setting up SSH tunnel is an effective solution, for example, if you want to log into the remote...

How to add an SSH key on the server?

In order to allow other users to log in to your server, you need to add the public SSH keys of...

How to generate SSH key?

To generate an SSH key in Windows you will need an additional application. In case of Linux or...

How do I log in to server with FileZilla?

Not everyone needs/can use the SSH connection and there is nothing wrong with it. But how to...

Configuration of backup space

Please note that usernames u00000 and u00000-sub1 are examples only. Please replace them with the...