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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-27-2010, 12:51 AM
|
#1
|
Member
Registered: Jun 2006
Location: Dubai
Distribution: Cent OS
Posts: 34
Rep:
|
/bin/sh: /etc/cron.d/redial: Permission denied
Hi,
I write following script.
#!/bin/bash
TEST=$(ifconfig | grep "ppp")
if [ -z "$TEST" ]
then
pptp xxx.xxx.xxx.37 call testVPN_original
fi
echo $TEST
SUB=${TEST:0:3}
YY="ppp"
echo $YY
echo $SUB
if [ $SUB == $YY ];
then
ping -c 2 192.168.0.2
route add default gw 192.168.0.2
fi
and named it as "redial" and set permission chmod u+x redial (chmod 755 redial)
ls -l
-rwxr-xr-x 1 root root 287 Jan 21 00:19 redial
I save this file in /etc/crond.d/redial
manually this script is running correctly but when I add this script to crontab it never runs. following is my crontab file.
SHELL=/bin/sh
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
HOME=/
22 5 * * * /usr/bin/perl /var/adm/bin/registry.pl > /dev/null 2>&1
16 * * * * /var/lib/asterisk/bin/freepbx-cron-scheduler.php
22 20 * * * /etc/webmin/cron/tempdelete.pl
2 * * * * /bin/sh /etc/cron.d/redial
2 * * * * /bin/sh /etc/cron.d/redial is not running by crontab producing following error
/bin/sh: /etc/cron.d/redial: Permission denied
I've following cron files
cron.d/
cron.daily/
cron.deny
cron.hourly/
cron.monthly/
crontab
cron.weekly/
no cron.allow file means all user are allowed.
cron.deny file is empty.
I don't have any idea regarding this deny.
Please help
|
|
|
01-27-2010, 01:16 AM
|
#2
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
One or two things are unclear here..
1) Near the end of your post, you list some FOLDERS, not files. And I don't believe the cron program you are using, actually cares what the names of those folders are; they are more for your convenience than for the cron program.
2) What cron program are you using? I am assuming Dillons Cron, but if I'm wrong, please tell us. If it is Dillons (which I use), I don't see in the man pages any reference to a "cron.allow" or 'cron.deny' file or folder. Are you sure this is relevant?
3) It looks like a simple permissions issue. I wonder if the fact that you have the "/bin/sh" on the crontab line is causing the problem. Dillons Cron executes commands using "/bin/sh -c" already, so putting /bin/sh there (considering that you already have a shabang atop your script anyway) may be the problem.
First thing I'd do, would be remove the /bin/sh from the crontab entry.
Sasha
Last edited by GrapefruiTgirl; 01-27-2010 at 01:17 AM.
Reason: typo
|
|
|
01-27-2010, 01:39 AM
|
#3
|
Member
Registered: Jun 2006
Location: Dubai
Distribution: Cent OS
Posts: 34
Original Poster
Rep:
|
Thanks for help.
1) cron.deny is file not directory
2) I'm not sure which cron program I'm using because I'm using CentOS 5 and cron is pre-installed.
3) yes remove /bin/sh from cron now it looks like following
SHELL=/bin/sh
PERL=/usr/bin/perl
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=""
HOME=/
22 5 * * * /usr/bin/perl /var/adm/bin/registry.pl > /dev/null 2>&1
16 * * * * /var/lib/asterisk/bin/freepbx-cron-scheduler.php
22 20 * * * /etc/webmin/cron/tempdelete.pl
2 * * * * /etc/cron.d/redial
but still not running
|
|
|
01-27-2010, 01:53 AM
|
#4
|
Member
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154
Rep:
|
problem may be is in
chmod u+x redial
this gives on my system
-rwxr-xr-x 1 AAA AAA 253 Jan 27 12:49 redial
which is not same as 755
for
chmod 755 redial
-rwxr-xr-x 1 AAA AAA 253 Jan 27 12:49 redial
|
|
|
01-27-2010, 01:56 AM
|
#5
|
Member
Registered: Jun 2006
Location: Dubai
Distribution: Cent OS
Posts: 34
Original Poster
Rep:
|
in
/var/log/cron
(*system*) BAD FILE MODE (/etc/cron.d/redial)
means what should I set
chmod 755 redial or chmod u+x redial
|
|
|
01-27-2010, 05:08 AM
|
#6
|
Member
Registered: Jun 2006
Location: Dubai
Distribution: Cent OS
Posts: 34
Original Poster
Rep:
|
Hi
(*system*) BAD FILE MODE (/etc/cron.d/redial) error has gone when I change my script's pemission from 755 to 644
now my cron log shows every 2 min it runs(read) /etc/cron.d/redial.sh
Jan 21 15:12:01 xxxx crond[6811]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:14:01 xxxx crond[6813]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:16:01 xxxx crond[6838]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:16:01 xxxx crond[6840]: (root) CMD (/var/lib/asterisk/bin/freepbx-cron-scheduler.php)
Jan 21 15:18:01 xxxx crond[6845]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:20:01 xxxx crond[6850]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:22:01 xxxx crond[6852]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:24:01 xxxx crond[6862]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:26:01 xxxx crond[6922]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:28:01 xxxx crond[6924]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:30:01 xxxx crond[6926]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:32:01 xxxx crond[6931]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:34:01 xxxx crond[6935]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:36:01 xxxx crond[6941]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:38:01 xxxx crond[6943]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:40:01 xxxx crond[6945]: (root) CMD (/etc/cron.d/redial.sh)
Jan 21 15:42:01 xxxx crond[6951]: (root) CMD (/etc/cron.d/redial.sh)
But never happen according to my script.
I don't know why it is not running when 755 is set as file permission.
Last edited by Farrukh Fida; 01-27-2010 at 05:17 AM.
|
|
|
01-27-2010, 05:39 AM
|
#7
|
Member
Registered: Jun 2006
Location: Dubai
Distribution: Cent OS
Posts: 34
Original Poster
Rep:
|
Hi everyone,
Thanks for your help. Now it is working fine.
I just change the script permission to
chmod u+x /etc/cron.d/redial.sh
and following is my crontab entry
*/2 * * * * /etc/cron.d/redial.sh
It runs after 2 mins and runs script(redial.sh)
This script is providing me consistent connection to my VPN server if VPN breaks it redial after 2 min.
Thanks.
Farrukh Fida.
|
|
|
01-27-2010, 09:55 AM
|
#8
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
Nice glad you got it sorted out.
So it appears that the script to be executed needed to have the .sh extension on it? Besides removing the /bin/sh from the front of the entry?
|
|
|
01-27-2010, 11:46 PM
|
#9
|
Member
Registered: Jun 2006
Location: Dubai
Distribution: Cent OS
Posts: 34
Original Poster
Rep:
|
Yes exactly
|
|
|
All times are GMT -5. The time now is 07:46 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|