LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Scheduled Tasks / Cron not working right? (https://www.linuxquestions.org/questions/linux-general-1/scheduled-tasks-cron-not-working-right-882180/)

Lossenelin 05-23-2011 12:42 AM

Scheduled Tasks / Cron not working right?
 
Got a small problem, I'm trying to schedule a script to run every Thursday at midday and the scheduled tasks application on Ubuntu doesn't seem to work. The script is fine when I run it from a terminal.

I have zero experience using cron at the command line, can anyone tell me what I should do?

acid_kewpie 05-23-2011 01:15 AM

well you could start by showing us the cron entry... How can we fix it without knowing what it is?

for a user crontab an example would be...

0 12 * * 4 /bin/sh /home/user/myscript.sh

i.e at 12:00 on the 4th day of the week run this script.

speck 05-23-2011 10:02 PM

The vast majority of these types of issues are caused by not specifying the full path to the programs inside the script. Cron does not run under the same environment as a normal user, so you should explicitly state the path to every script/program that is being executed.

Incorrect:
Code:

#!/bin/sh
clean_files /tmp /var/log/setup/tmp

Correct:
Code:

#!bin/sh
/usr/local/bin/clean_files /tmp /var/log/setup/tmp



All times are GMT -5. The time now is 04:06 AM.