SSH | Add a Cron Job
A corn is a time based job scheduler which runs automatically on unix-like server. It is use to schedule jobs or tasks to runs at fixted date, time or intervas.
for conducting a corn job in unix-like server. we need putty or ssh which is a secure shell or terminal emulator. this is use to access remote systems over the internet.
You need to connect your server via SSH. You can follow this guide on how to connect your server via SSH.
To display the on-line help for crontab enter:
Type crontab -e and press enter to get access to your server crontab.To make it editable, just press the “insert” button on keyboard.
Info: A crontab is a simple text file in your server which contain a list of commands meant to be run at fixted times.
Now you can add or edit your cron jobs or schedules.
Before you start, lets have a look on the cron jobs formate.
┌───────────── min (0 – 59) │ ┌────────────── hour (0 – 23) │ │ ┌─────────────── day of month (1 – 31) │ │ │ ┌──────────────── month (1 – 12) │ │ │ │ ┌─ day of week (0 – 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat) │ │ │ │ │
* * * * * /path/to/your/script.sh * * * * * => Run every minute 0 * * * * => Run every Hour 0 0 * * * => Run every midnight 0 0 0 * * => Run every Month 0 0 0 0 * => Run every Weekdays
After you’re done editing, press the “Esc” key on your keyboard to exit from the edit mode. It will again look like this:
To exit cron tab, you should type ":wq"and press enter.