MEETING WITH CRONTAB

While working on the Nestpay project, I came across the use of crontab, a system I wasn't familiar with until then. Let me start by explaining what Crontab is.

Crontab (Cron Tables) is a scheduling manager in Unix and similar operating systems, allowing for the automatic execution of timed tasks. It's managed by a service called "cron". The crontab file specifies the commands users or system administrators want to run at specific intervals or on specific dates and times.

Using crontab, system administrators can automate recurring tasks, such as file backups, clearing log files, database maintenance, and more, thereby facilitating system management.

Let me now explain what I did with Crontab.

As a first step, I prepared a shell script named hello.sh.

#!/bin/bash

echo "Hello, World!" >> /home/emre/Desktop/hellocron.txt

This file simply appends the text 'Hello, World!' to the hellocron.txt file every time it runs

Then, I used the 'crontab -e' command to edit crontab and set up the hello.sh file to run every minute.

* * * * * /usr/bin/bash /home/emre/Desktop/hello.sh

As a result, a new 'Hello, World!' message was added to the hellocron.txt file every minute. Finally, I inspected the /var/log/syslog file to monitor tasks executed by crontab and observed that the hello.sh file was running regularly every minute. This experience demonstrated how powerful automating scheduled tasks can be and how it simplifies system management


Sep 13 11:10:01 eker CRON[3457]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)

Sep 13 11:10:12 eker crontab[3453]: (emre) REPLACE (emre)

Sep 13 11:10:12 eker crontab[3453]: (emre) END EDIT (emre)

Sep 13 11:11:01 eker cron[535]: (emre) RELOAD (crontabs/emre)

Sep 13 11:11:01 eker CRON[3477]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)

Sep 13 11:12:01 eker CRON[3482]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)

Sep 13 11:13:01 eker CRON[3489]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)

Sep 13 11:14:01 eker CRON[3524]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)

Sep 13 11:15:01 eker CRON[3530]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)

Sep 13 11:15:24 eker systemd[957]: Started KWrite - Metin Düzenleyici.

Sep 13 11:15:34 eker systemd[957]: app-org.kde.kwrite-9e04fe8fca7d4b2b8f9f77af440caa8c.scope: Succeeded.

Sep 13 11:15:55 eker systemd[957]: Started Kate - Gelişmiş Metin Düzenleyici.

Sep 13 11:15:57 eker systemd[957]: app-org.kde.kate-20b67edd6dfb47cb80b8b3b379ce002a.scope: Succeeded.

Sep 13 11:16:01 eker CRON[3627]: (emre) CMD (/usr/bin/bash /home/emre/Desktop/hello.sh)