LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2011, 04:41 AM   #1
jedi777
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Rep: Reputation: 0
Script crontab


Hello! I have a script(urls.sh) scheduled to run with Crontab at every hour. The script is all good and executes manually with [root@server cron.hourly]# ./urls.sh
But the scrip is not executing according to schedule.
This is what I see in /var/log/cron every hour:
crond[4729]: (root) CMD (run-parts /etc/cron.hourly/urls.sh)

My crontab look likes this:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly/urls.sh
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


Any suggestions?

//Jedi
 
Old 01-26-2011, 04:52 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Hi and welcome to LinuxQuestions!

The system crontab /etc/crontab uses the run-parts command to run all the executable files inside the specified directory. You cannot put a file as argument to run-parts. Most likely the cron daemon has sent an error to root's mail, as
Code:
Not a directory: /etc/cron.hourly/urls.sh
Leave the /etc/crontab file untouched and simply put the script inside the /etc/cron.hourly directory. Be sure it has executable permissions.

In alternative you can use the user's (or root's) specific crontab, using crontab -e.
 
Old 01-27-2011, 12:52 AM   #3
jedi777
LQ Newbie
 
Registered: Jan 2011
Posts: 2

Original Poster
Rep: Reputation: 0
Hi!
Many thanks for your input, the scrip is executing according to schedule.

Previous I also had to add the following argument to pam_access in /etc/pam.d/crond:
account required pam_access.so accessfile=/etc/security/access-cron.conf.
And an empty file:
# touch /etc/security/access-cron.conf

Otherwise I got:
server pam_access[1566]: access denied for user `root' from `cron'
server crond[1566]: Permission denied

Many thanks!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Crontab not running script j8177e5 Linux - Newbie 2 12-21-2010 08:54 AM
Runs Multiple shell script inside a main script using crontab srimal Linux - Newbie 4 10-22-2009 06:19 PM
script no values if in crontab packets Programming 1 03-12-2009 06:29 PM
crontab and a bash script seefor Linux - General 6 01-27-2009 03:41 PM
Script having problem with Crontab DriveMeCrazy Programming 5 07-18-2005 03:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration