LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-25-2016, 03:23 AM   #1
sunweb
LQ Newbie
 
Registered: Jun 2012
Distribution: Kubuntu 14.04
Posts: 7

Rep: Reputation: Disabled
Run a script on shutdown before network goes off


Hi. Using K/X/Ubuntu 14.04, but it doesn't really matter as it should be the same in Debian as well.
It doesn't matter how simple script is, it can be:
echo "put it" > /media/network/there
echo "put it" > /home/user/there

If i will put it a link to script to /etc/rc0.d with K04script name it will create file only on local machine, even if i put it in rc3.d and rc5.d with S04script it still doesn't work.

Can someone help me?
 
Old 01-25-2016, 05:03 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,008

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
Maybe symbolic link? http://unix.stackexchange.com/questi...down-in-debain
 
Old 01-26-2016, 02:29 AM   #3
sunweb
LQ Newbie
 
Registered: Jun 2012
Distribution: Kubuntu 14.04
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thats exactly what i did. The script runs but not before network goes down or network disks are unmount.
 
Old 01-26-2016, 04:00 AM   #4
sunweb
LQ Newbie
 
Registered: Jun 2012
Distribution: Kubuntu 14.04
Posts: 7

Original Poster
Rep: Reputation: Disabled
Ok, i've found a solution. Though i believe there should be a better way to do it as creating services just for that sounds strange.
Workaround using Upstart(i guess i'd have to write units if systemd will be used for this case as well).

create a file /etc/init/your_name.conf

if you want bash autocompletion to work put a link to /etc/init.d without ".conf" (/etc/init.d/your_name). Though i didn't try with it maybe it'll work too. In my case not needed anyway but if you'll write a script directly in *.conf and want to test it maybe useful.

Put quoted inside of /etc/init/your_name.conf
Quote:
# The deconfiguring-networking bit stops the network from going down until we are done here.

description "Script on shutdown"

start on runlevel [016] or deconfiguring-networking

#exec sh /path/to/script

# or

script

<script body here>

end script
found a solution here -> http://unix.stackexchange.com/questi...eds-network-on
 
  


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
Run script at shutdown Fixit7 Puppy 2 01-06-2015 06:27 AM
script to run before server shutdown vaishlinux Red Hat 6 04-04-2014 09:11 AM
Run the script at machine shutdown. trumtrak Linux - Newbie 2 03-18-2013 07:38 AM
Run script on shutdown or reboot VeeDubbs Linux - Server 1 10-23-2008 01:34 PM
How to run a script at startup after a shutdown? kklein9 Linux - Software 3 01-27-2006 03:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 06:58 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
Open Source Consulting | Domain Registration