LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 03-14-2011, 03:14 AM   #1
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 570

Rep: Reputation: 31
Howto stop squid before executing crontab file?


Hi,
I am using squid 2.6 on my cent os 5 .I want to shutdown the system at 7:00 pm for that purpose I write in
# crontab -e

0 19 * * * /sbin/shutdown -h now

The thing which I want to clear that when the system will going to turn off it will also stop squid service? If not then how can I automatically stop squid service and then crontab file execute ?
kindly guide me
garden
 
Old 03-14-2011, 03:16 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Slackware 14.0
Posts: 8,464

Rep: Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877Reputation: 877
Quote:
The thing which I want to clear that when the system will going to turn off it will also stop squid service?
Since you shutdown the system, all running processes will be turned off.

Kind regards
 
Old 03-14-2011, 03:18 AM   #3
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello,

Normally your system should take care of that. You can have a look in the /etc/rc.d/rc0.d folder to check when (in what order) your services are shutting down. The higher the number, the later the service will stop. This is done so that dependent services get stopped before the service they depend on.

Kind regards,

Eric
 
Old 03-14-2011, 03:35 AM   #4
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 570

Original Poster
Rep: Reputation: 31
Thnks for the reply. I can check it by
# vi /etc/rc.d/rc0.d

what you say If I a script may work


Code:
vi /root/auto_shutdown_script

#!/bin/bash

/etc/init.d/squid stop > /dev/null 2> /dev/null

if [ $? -eq 0 ]
then
shutdown -h now > /dev/null 2> /dev/null
fi



Step..2

crontab -e

* 19 * * * sh /root/auto_shutdown_script > /dev/null
 
Old 03-14-2011, 04:03 AM   #5
kaushalpatel1982
Member
 
Registered: Aug 2007
Location: INDIA
Distribution: CentOS, RHEL, Fedora, Debian, Ubuntu, LinuxMint, PCLinuxOS
Posts: 132

Rep: Reputation: 5
While you shutting your system, All services running on the server will going to shutdown.

Just shutdown the system and forget everything.
 
Old 03-14-2011, 11:38 PM   #6
gardenair
Member
 
Registered: Oct 2004
Location: LH
Posts: 570

Original Poster
Rep: Reputation: 31
EricTRA as you mentioned in your post You can have a look in the /etc/rc.d/rc0.d folder to check when (in what order) your services are shutting down. How can I check it ?
kindly just explain it
thanks
garden
 
Old 03-15-2011, 02:42 AM   #7
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hello,

Just do:
Code:
ls /etc/rc.d/rc0.d
You'll get a list of links to scripts in init.d beginning with either K (Kill) or S (Start). The initial letter is followed by a number which indicates the sequence in which the scripts will start. If beginning with K then the stop command will be passed to the script in init.d to which the link references. If beginning with an S then the start command will be passed.
Code:
K01dnsmasq -> ../init.d/dnsmasq
K01smartd -> ../init.d/smartd
K02avahi-daemon -> ../init.d/avahi-daemon
K02avahi-dnsconfd -> ../init.d/avahi-dnsconfd
K02NetworkManager -> ../init.d/NetworkManager
K02oddjobd -> ../init.d/oddjobd
K03yum-updatesd -> ../init.d/yum-updatesd
S00killall -> ../init.d/killall
S01halt -> ../init.d/halt
Above is a list of some of the links in a CentOS server. You'll see that dnsmasq and smartd get stopped (Kill) before avahi-daemon and so on. The scripts starting with S are there to kill remaining processes, remove lock files and some other actions before the system is halted. You can check the contents of either of the init.d script to see what they do exactly.

At this link you can find some more basic information about runlevels and init scripts.

Kind regards,

Eric
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seems crontab is not executing script... jonaskellens Linux - Newbie 3 11-18-2010 08:20 AM
crontab job not executing.... mia_tech Linux - Newbie 6 08-31-2009 02:42 PM
Command for executing C program in crontab bhandu Linux - Newbie 1 07-14-2007 12:54 PM
Howto play a sound file just before linux stop ? zghh Linux - Software 1 01-11-2007 05:24 AM
how to stop Email file through Squid ashfaq Linux - Security 1 05-04-2006 01:11 AM


All times are GMT -5. The time now is 07:25 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration