Cron job with shell script

i am trying to run a shell script using cronjob after every 2 minutes. I opened my terminal then typed

crontab-e

once i execute this command i am writing my command

*/2 * * * * /home/test/test/test.sh

but i am getting an error as

E486: Pattern not found: 2 * * * *

please help as i am new to this and i don't know why it is happening. If you give me any links and code on hwo to execute cronjob it would help.


Solution 1:

As mentioned in comments, the following error:

E486: Pattern not found: 2 * * * *

Was caused because you were not editing properly. That is, you were saying crontab -e correctly and then you were entering in vi. Instead of going into the insert mode, you would directly type */2 * * * * /home/test/test/test.sh, which vi would try to perform as a command, which is not.

So what you have to do is to press i to enter in the write mode. And then, just then, write */2 * * * * /home/test/test/test.sh. Finally, save the file by saying :wq.

In case other problems occur in your cronjob, you may want to check the "Debugging crontab" section in https://stackoverflow.com/tags/crontab/info.