LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   [cron] Root cron ib centos 6.3 doesn't work/ (https://www.linuxquestions.org/questions/linux-newbie-8/%5Bcron%5D-root-cron-ib-centos-6-3-doesnt-work-4175440681/)

killout 12-09-2012 11:45 AM

[cron] Root cron ib centos 6.3 doesn't work/
 
Hello, kind forum.

My os is:

Code:

[root@livestreet var]# uname -a
Linux livestreet 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Code:

[root@livestreet var]# cat /etc/redhat-release
CentOS release 6.3 (Final)

And I can't get root cron to work.
After reading this doc ,I have added line to /etc/crontab:

cat /etc/crontab
Code:

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

0-59/1 * * * * root  ls /proc >> /tmp/proc

After that i have tried to restart crond, and reboot computer, but nothing happens.

Code:

[root@livestreet log]# tail /var/log/cron
Dec  9 20:01:01 livestreet CROND[4122]: (root) CMD (run-parts /etc/cron.hourly)
Dec  9 20:01:01 livestreet run-parts(/etc/cron.hourly)[4122]: starting 0anacron
Dec  9 20:01:01 livestreet run-parts(/etc/cron.hourly)[4131]: finished 0anacron
Dec  9 20:55:01 livestreet crond[3236]: (*system*) RELOAD (/etc/crontab)
Dec  9 21:01:01 livestreet CROND[4160]: (root) CMD (run-parts /etc/cron.hourly)
Dec  9 21:01:01 livestreet run-parts(/etc/cron.hourly)[4160]: starting 0anacron
Dec  9 21:01:01 livestreet run-parts(/etc/cron.hourly)[4169]: finished 0anacron
Dec  9 21:22:52 livestreet crond[4197]: (CRON) STARTUP (1.4.4)
Dec  9 21:22:52 livestreet crond[4197]: (CRON) INFO (running with inotify support)
Dec  9 21:22:52 livestreet crond[4197]: (CRON) INFO (@reboot jobs will be run at computer's startup.)

Code:

[root@livestreet log]# tail /var/log/messages
Dec  9 03:13:02 livestreet rsyslogd: [origin software="rsyslogd" swVersion="5.8.10" x-pid="1078" x-info="http://www.rsyslog.com"] rsyslogd was HUPed

And there is no file /tmp/proc

In my /etc/anacrontab there is no cron.hourly task like in this thread. Is that correct?
Code:

[root@livestreet etc]#  cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days  delay in minutes  job-identifier  command
1      5      cron.daily              nice run-parts /etc/cron.daily
7      25      cron.weekly            nice run-parts /etc/cron.weekly
@monthly 45    cron.monthly            nice run-parts /etc/cron.monthly


Is /etc/crontab a right place for editing root cron jobs?

shivaa 12-09-2012 12:49 PM

First of all, before editing such important file, do take backup of it, so in case of any pb, it can be restored (I hope you did that).
Well, in order to add a cron job, you need NOT to manually edit /etc/crontab file, but you can simply open it for editing using cmd:
Code:

crontab -e

For example, to run a job daily at 3 pm, add:
0 15 * * * <command>

It will open the file in vi (or in your default editor), however add your cron job entry, save and quit.. That's all.
To check already running cron jobs, invoke:
Code:

crontab -l
(Note: I am not sure, what format is used for adding a cron entry in CentOS. So check the format of making a cron entry before any editing. Rest commands mentioned will work fine.)

killout 12-17-2012 01:26 PM

The answer is new line at the end of /etc/crontab.

Cron began to works after adding new line next to last job.


All times are GMT -5. The time now is 09:49 PM.