LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-09-2012, 06:03 PM   #1
ggalan
Member
 
Registered: Oct 2010
Posts: 57

Rep: Reputation: 0
apachectl graceful error from cron


i have a cron file that reloads apache using
Code:
RELOAD="/usr/sbin/apachectl graceful"
but in the log i get an error
Code:
(13)Permission denied: Error retrieving pid file run/httpd.pid Remove it before continuing if it is corrupted.
ive tried
Code:
RELOAD="/usr/sbin/sudo apachectl graceful"
with no luck. do i need to own a folder or give special permission somewhere?

just tried
Code:
RELOAD="sudo /usr/sbin/apachectl graceful"
and got
Code:
sudo: sorry, you must have a tty to run sudo

Last edited by ggalan; 01-09-2012 at 09:02 PM.
 
Old 01-09-2012, 07:27 PM   #2
trbennett48
LQ Newbie
 
Registered: Apr 2011
Location: Oregon
Posts: 25

Rep: Reputation: 3
Two things:

- is RELOAD="/usr/sbin/apachectl graceful" the correct format for a crontab file????
I don't have Linux, but I use AIX, and its crontab file has this format:
Code:
minute  hour  day_of_month  month  weekday  command
Example for running "graceful" at 10:05 AM
Code:
05  10 * * * /usr/sbin/apachectl graceful
- Rather than trying to use "sudo"... put the graceful command in ROOT's crontab...

-tony
 
Old 01-09-2012, 07:31 PM   #3
ggalan
Member
 
Registered: Oct 2010
Posts: 57

Original Poster
Rep: Reputation: 0
the crontab is
Code:
0  */2  *  *  * /usr/local/bin/check.sh httpd /etc/httpd/conf.x/cronfile >> /var/log/date.log 2>&1
check.sh
Code:
#!/bin/bash

if [[ $# -ne 2 ]]
then
    echo "<*> usage: $0 <service> <target_file_to_monitor>"
    exit 0
fi

SERVICE=$1
TARGET=$2
SHORTNAME=$(basename $TARGET)
RELOAD="sudo /usr/sbin/apachectl graceful"

touch ./last_checksum_$SHORTNAME
md5sum $TARGET > ./current_checksum_$SHORTNAME
$(diff -q ./last_checksum_$SHORTNAME ./current_checksum_$SHORTNAME > /dev/null 2>&1 )
if [[ $? -eq 0 ]]
then
    echo "[*] no change `date`, week `date +"%V"`"
else
    echo "[*] $TARGET modified `date`, week `date +"%V"`"
    $RELOAD
    cp ./current_checksum_$SHORTNAME ./last_checksum_$SHORTNAME
fi
 
Old 01-09-2012, 08:56 PM   #4
ggalan
Member
 
Registered: Oct 2010
Posts: 57

Original Poster
Rep: Reputation: 0
think i got it
Code:
0  */2  *  *  * sudo /usr/local/bin/check.sh httpd /etc/httpd/conf.x/cronfile >> /var/log/date.log 2>&1
but had to edit
sudo nano /etc/sudoers

then add
Defaults:%USER-NAME !requiretty
Defaults:USER-NAME !requiretty

Last edited by ggalan; 01-09-2012 at 09:02 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Cron error: help with cron and changing system time hbbtstar Linux - Software 1 10-15-2009 10:10 PM
Graceful startup and shutdown? Shilo Carson Linux - General 25 03-22-2007 10:26 AM
FVWM: graceful exit yozhhh Linux - Software 1 01-17-2006 08:56 AM
apachectl start error emsky Linux - Newbie 1 04-04-2004 01:16 AM
apachectl startssl error message harlow400 Linux - Software 2 03-01-2004 03:31 AM

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

All times are GMT -5. The time now is 10:18 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration