Newbie
Newbie

Reputation: 57

sh with crontab is not working in Centos

I am testing an sh script with crontab which simply creates a file

 #!/bin/bash
    PATH=$PATH:/bin:/usr/bin
    TMP_FILE=/home/hmm/AppFlatForRent/i_am_running
    touch "$TMP_FILE"

Now I want to run it on crontab and have used the following but failed

18 10 * * * sh /home/hmm/AppFlatForRent/hello.sh

Also this one

18 10 * * * usr/bin/sh /home/hmm/AppFlatForRent/hello.sh

I am also trying this

23 12 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
23 12 * * * /home/hmm/AppFlatForRent/hello2.sh

Anyone knows whats the problem?

Solution: 23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh

This works!

Upvotes: 0

Views: 2518

Answers (1)

John Morris
John Morris

Reputation: 721

Give the full path to the shell from cron starting with '/':

18 10 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh

Or just leave the shell out and run the script directly if it is executable:

18 10 * * * /home/hmm/AppFlatForRent/hello.sh

Upvotes: 1

Related Questions