LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Crontab not working as expected (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-not-working-as-expected-357400/)

nro 08-26-2005 10:15 PM

Crontab not working as expected
 
Hello,
To begin, I have made a file called 'mikecron'. In this file, there is 1 line to set a cron job for the following:
*/5 * * * * /home/mikie/hlds_l/cstrike/hltv_autozipdemos

According to the syntax, this should be a correct line for crontab.

I have a bash script called 'hltv_run':

Code:

#/bin/sh
# hltv_run - Script for starting the HLTV server

# Start crontab for auto zip
crontab -r
crontab mikecron

When I run 'hltv_run'(using ./hltv_run) is executes fine. When I type 'crontab -l' I am able to see my crontab jobs.

Everything seems to be set up correctly however for some reason the job is not executing! If you have any idea why this might not be working, please let me know.

Thanks,
Mike

mercyop 08-27-2005 12:57 AM

Do you want crontab to execute that script every 5 minutes? If so this is what I would have used:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/mikie/hlds_l/cstrike/hltv_autozipdemos

archtoad6 08-27-2005 03:01 AM

The "FM" on my SimplyMEPIS says that */5 means every 5 min. (Search the man page for the word "step".)

I don't think your problem is your syntax, but rather the name & location of the file -- How did you create the file & what dir did you put it in??

rhoekstra 08-27-2005 03:44 AM

I have tested something similar on my FC4 machine and works without problems.
I created a file 'test' with this content:

Code:

* * * * * echo "yes"|mail robert
I executed 'crontab test' and the mails started coming in.

So either one of your scripts aren't working (x-bit not set?) or they don't have anything to do... please create some similar test script to identify if it is cron that is not working . . . Then move on to the next step (having YOUR scripts to be executed). For instance, let your own script explicitly send an e-mail to you that it is being executed, on the first line of the script.

I hope this helps a bit ?

Good luck

Oh, and PS, your first line is not correct, it should read '#!/bin/bash' instead of '#/bin/bash' But I guess that's just a minor detail, as your machine will probably pick bash as the interpreter anyway.

nro 08-27-2005 12:37 PM

The script runs fine, I'm not too worried about that. I'm pretty sure the script is in the right spot. Is there a way to check exactly what my absolute path is from the directory with the script? I simply used $HOME and then added my directories on.

Thanks,
Mike

jailbait 08-27-2005 01:14 PM

"I simply used $HOME and then added my directories on."

cron jobs do not run as either root or user. $HOME for cron is probably null. For sure it is not /root or /home/mikie. So your problem is probably that the absolute path to the command is correct when testing but wrong when running as cron.

-------------------------
Steve Stites

nro 08-27-2005 07:18 PM

I have just tried to run by simply typing:
/home/mikie/hlds_l/cstrike/hltv_autozipdemos

And the file I want does run.

Any ideas...?

archtoad6 08-29-2005 12:56 PM

Quote:

Originally posted by archtoad6
I don't think your problem is your syntax, but rather the name & location of the file -- How did you create the file & what dir did you put it in??
For the second time:
  • Where is the "file called 'mikecron'"?
  • How did you create it? (What editor???)

Please be so kind as to answer or I cannot help.


All times are GMT -5. The time now is 12:03 AM.