Crontab – where is it and how to add the task

Crontab is a more flexible and low-level analog of the Windows Task Scheduler for Linux 🙂 Personally, I prefer crontab and the Linux console over the Windows GUI, and definitely more than any GUI for Linux.

It isn’t easy to remember where a file is located in the file system, especially when you only deal with it once in a while. So I’ll write down a few quick tips on Crontab here.

Where the crontab file is located:

It is located at /var/spool/cron/crontabs

This directory contains text files named after the users under whose authority the tasks will be executed.

To schedule a task to run a script, you need to add a line like

0 */2 * * * /var/www/admin/www/tools/mybashscript.sh

where the execution frequency comes first, followed by the target to execute. In the example above, the script runs every 2 hours.

An awesome collection of how to write task schedules is gathered on the page https://crontab.guru/examples.html.

Leave a Reply

Your email address will not be published. Required fields are marked *

Let us know you are human: