Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

I am having a simple cron job at my fedora linux i.e. to halt the machine at given time. But my cron job is not getting activated at all. Pl. guide me regarding this.

Regards.

Milind

asked 05 May '10, 11:24

Milind's gravatar image

Milind
1112
accept rate: 0%

edited 05 May '10, 12:05

feinom's gravatar image

feinom
2195

Please accept an answer, or provide more details on what you're looking for.

(14 Jun '11, 11:45) rfelsburg ♦



You can trace this problem. Look in /var/log/cron and see if there are errors. If there are none, you may not be running cron with adequate logging. Look in your startup scripts for where crond starts. I'm not totally familiar with Fedora, but go to /etc/rc3.d or /etc/init.d and "grep crond *" and find which script starts crond. They use -lnn for the loglevel. I use -l10 for a lot of logs because I want to know what the problems are. Change it so it starts with a higher number like 10.

Cron problems usually revolve around the shell. When crond triggers an action, it starts without your normal shell. If you are relying on a PATH or other environment variables, they are not going to be available. You need to hard code the location of executables. Like, instead of

10 4 * * * my_script

You need to explicitly state where it is, like this:

10 4 * * * /home/brian/bin/my_script

Some environment variables are available to you, like $HOME.

If you want to see what is available, set up a cron job like this:

10 4 * * * set > $HOME/cron_set.txt

so that it goes off in the next minute or two, then look in the output file and see what environment variables are available to you.

link

answered 05 May '10, 14:35

codebunny's gravatar image

codebunny
40816
accept rate: 38%

edited 05 May '10, 15:23

Could you please provide some more details?

What does your cronjob look like?

Are you using "crontab -e" to edit it, and are you doing it as root?

link

answered 05 May '10, 11:31

feinom's gravatar image

feinom
2195
accept rate: 33%

Also make sure your cron daemon is running. There are a variety of daemons out there so I am not sure which one you are using however they all genereally contain the word "cron" so using the below command should be sufficient;

ps aux | grep cron

(05 May '10, 16:10) gjcwilliams

Check is the /etc/init.d/crond service is working & is on when system boot.

/etc/init.d/crond status

link

answered 06 May '10, 07:53

Nitin's gravatar image

Nitin
1
accept rate: 0%

i hope you tell me if this works or not???

service crond status [if you are using crontab ] or

service atd status [if you are using at]

if the command replied you as running then i suppose you want to poweroff the machine i do it in my RHEL 5.5 this way at 10 pm

at 2000

at > poweroff

CTRL+D [twice] [this will run only once if you do a crontab it will execute repetedly at the same time write back i will guide you to that too] hope it helps a bit.

link

answered 07 May '10, 13:59

rituraj.goswami's gravatar image

rituraj.goswami
211
accept rate: 0%

I suggest tailing /var/log/cron to see what jobs are getting run.

tail -f /var/log/cron

I've also seen cronjobs hang indefinitely (because the jobs started don't exit in a timely fasion). Checking the number of crond instances can expose a situation where jobs are starting, piling up, and not exiting.

pgrep crond

If you have a pile of them, use can use ps -elf or pstree to see which script is causing problems.

link

answered 11 May '10, 20:46

memnoch_proxy's gravatar image

memnoch_proxy
1413
accept rate: 42%

The simplest answer is usually "permissions". If your trying to shutdown the system, assuming your cron syntax is correct, I'm going to assume that you're doing it as a regular user. If that's the case then you probably just don't have rights to shutdown the system.

link

answered 13 May '10, 14:36

JD50's gravatar image

JD50
512
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×24
×7

Asked: 05 May '10, 11:24

Seen: 9,548 times

Last updated: 14 Jun '11, 11:45

powered by OSQA