1

I have a shellscript which can be successfully executed in UNIX with command sh Shell_script.sh; but I want it to run automatically. So I just configured a cronjob to run the script using crontab -e.

The cronjob added is below:

0 7-23 * * * * /home/folder1/folder2/Shell_script.sh > /dev/null 2>&1

I want it to be executed hourly from 7AM to 11PM every day.

My shell script has a she-bang #!/bin/bash. I am getting a mail every hour with the content:

Your "cron" job on servername * /home/folder1/folder2/Shell_script.sh > /dev/null 2>&1

produced the following output:

sh: +61: execute permission denied

1 Answer 1

2

You have extra * in your cron line which is interpreting as Username. Once you delete it it will be fine executed.

also consider if your Shell_script.sh is not executable, you need run with sh (if it's written in sh) or bash if it's bash written.

0 7-23 * * * bash /home/folder1/folder2/Shell_script.sh > /dev/null 2>&1
6
  • 1
    Thank you for pointing out my mistake. I have edited my cronjob. Hope it works in the next execution.
    – Devjith
    Aug 30, 2018 at 6:19
  • 1
    Thanks and Welcome. One things that I noticed you are as a new user in Unix.stackexchange.com community and other SO had several questions without accepting the answer. considering please take your time and accept the one which solved your question. thank you again Aug 30, 2018 at 6:25
  • Will I get any mail while running cronjob if my script is not executable?
    – Devjith
    Aug 30, 2018 at 6:43
  • if you run with bash your_script.sh you no need to worry about executable. you can make it executable with chmod +x your_script.sh. I never used cron to sending mail, so not sure if it will send mail if was not able to execute, but that's sounds it should be Aug 30, 2018 at 6:51
  • Thank you so much....Its working fine now....Also used chmod +x your_script.sh.
    – Devjith
    Aug 30, 2018 at 7:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .