Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
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.
|
|
03-14-2011, 04:14 AM
|
#1
|
Member
Registered: Oct 2004
Location: LH
Posts: 648
Rep:
|
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
|
|
|
03-14-2011, 04:16 AM
|
#2
|
LQ 5k Club
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529
|
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
|
|
|
03-14-2011, 04:18 AM
|
#3
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
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
|
|
|
03-14-2011, 04:35 AM
|
#4
|
Member
Registered: Oct 2004
Location: LH
Posts: 648
Original Poster
Rep:
|
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
|
|
|
03-14-2011, 05:03 AM
|
#5
|
Member
Registered: Aug 2007
Location: INDIA
Distribution: CentOS, RHEL, Fedora, Debian, Ubuntu, LinuxMint, Kali Linux, Raspbian
Posts: 166
Rep:
|
While you shutting your system, All services running on the server will going to shutdown.
Just shutdown the system and forget everything.
|
|
|
03-15-2011, 12:38 AM
|
#6
|
Member
Registered: Oct 2004
Location: LH
Posts: 648
Original Poster
Rep:
|
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
|
|
|
03-15-2011, 03:42 AM
|
#7
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Hello,
Just do:
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
|
|
|
All times are GMT -5. The time now is 08:33 AM.
|
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
|
|