Minutes are the part of hour we want , value must be between 0-59, suppose you want task to be execute on 12 th minute of hour then the value of minute should be 12, If you want to execute a task on each minute then value should be * .
Value must be between 0-23, suppose you want task to be execute on 12 th hour of day then the value of hour should be 12, If you want to execute a task on each hour then value should be * .
Value must be between 1-31, suppose you want task to be execute on 12 th day of month then the value of day should be 12, If you want to execute a task on each day then value should be * . While adding value we recommend adding value less than 29 because , it will execute in feb in value >28
Value must be between 1-12, suppose you want task to be execute on 12 th month of year then the value of month should be 12, If you want to execute a task on each month then value should be * .
Value must be between 0-6, suppose you want task to be execute on 3 th day of week then the value of day should be 3, If you want to execute a task on each day then value should be * . [Note : Some systems supports 7 as sunday. Please check compatibility before using]
Value should be your Username or root or bash , depends on your config.
Enter path of script, or read guide below
# ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of the month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday; # │ │ │ │ │ 7 is also Sunday on some systems) # │ │ │ │ │ # │ │ │ │ │ # * * * * *
$ sudo touch ~/filenamehereMaking changes here
$ nano ~/filenamehereenter all the commands here which you want to execute. for example
#!/bin/bash sudo service apache2 restart sudo apt update sudo apt upgrade -y sudo apt autoremove -y sudo rebootNow press Ctrl + X and then press y & click enter. This will save your file.
sudo chmod +x ~/filenamehereNow the last bit, add it to your crontab. To do that, type in
crontab -eWhen the file opens at the bottom of it, Copy output from above and paste on bottom line then Save the file and exit from it. To make sure you’ve added the cron, type in
crontab -lYou should see the command you added at the bottom. Some of above content is copied from this post of JustInClicks.com Blogs . Please visit link to get more details.