Sometimes we need to run a shell script at some regular intervals, like once everyday. We can do this using cron. In this tutorial we will see how to run a shell script using cron.
Shell Script file
Let’s assume our shell script file is located at:
Create your cron command so that we can run the shell script at a regular interval. We recommend crons.in for generating cron command.
Let’s assume we want to run the shell script every hour. So, we will use below cron command.
0 * * * *
Login to your Linux system via SSH and use below command to open crontab.
Add below code in crontab to run our shell script every hour.
0 * * * * /root/my_script.sh