라벨이 automation인 게시물 표시

How to set up crontab and check if it works

What is crontab? crontab is a command that allows you to schedule periodic tasks on Linux. For example, you can use crontab to automate tasks such as backing up every night, deleting logs every Monday, or checking system status every hour. crontab can be divided into two types: System-wide crontab: Tasks defined in the /etc/crontab file that are shared by all users. Individual user’s crontab: Tasks that each user creates and manages with the crontab command that only the user can access. In this post, we will learn about the individual user’s crontab and how to set it up and check if it works. How to set up crontab The crontab command has the following options: -e: Edit the crontab file. By default, the vi editor opens, but you can use a different editor by setting the EDITOR environment variable. -l: Print the contents of the current crontab file. -r: Delete the current crontab file. To edit the crontab file, enter the following command: 1 $ crontab -e cs Then you can define tasks in