1

I have a very simple script in my crontab that I want to run every day. It is located in /home:

-rwxr-xr-x 1 root        root     40 Apr 15 08:01 kill_slony_stop_sql.sh

It has execute permission and here is the content:

#!/bin/bash
slon_kill;rcpostgresql stop

and here is the cron line for it to run daily:

56 12 * * * /home/kill_slony_stop_sql.sh

But it is not working for some reason. When I type /home/kill_slony_stop_sql.sh in the command line, it works good but it is not working in the crontab.

Any thoughts?

1
  • Please review the crontab tag wiki for troubleshooting tips. This is a very common FAQ and usually not programming-related at all. Commented Apr 15, 2015 at 13:06

2 Answers 2

1

It is most likely a PATH issue. Have a look at Why is my crontab not running and be sure to set a PATH so that it can call your slon_kill command.

Also, add some debug to your cron

56 12 * * * /home/kill_slony_stop_sql.sh &>/tmp/errorcron.log

And also look at the logs; cron logs its actions via syslog, which (depending on your setup) often go to /var/log/cron or /var/log/syslog.

Sign up to request clarification or add additional context in comments.

Comments

0

I had the same problem with a daily cron job, I used the @daily but this will run at 00:00 every day.

@daily /usr/local/bin/msa70_check.sh

was the cron tab line i added, below is the script i run.

#!/bin/bash
# msa70 disk check
/sbin/mdadm --detail /dev/md0 /dev/md1|
/bin/mailx -s"Disk check on server123 please check" [email protected]

I also had to edit my script and add /sbin/ and /bin in front of mdadm and mailx for the cron job to run

2 Comments

I am not sure it is a astersik problem since I have many other tasks that works with that notation, and I need it to run at that specific time because the trafic on the server will be low
thanks paul It worked after adding before each command the complete path, I actually located the slon and rcpostgresql commands and fixed the script to the following: #!/bin/bash /usr/bin/slon_kill; /usr/sbin/rcpostgresql stop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.