Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #174662 > unrolled thread

How to run a script before shutdown?

Started byRobert Latest <boblatest@gmail.com>
First post2016-11-13 20:40 +0100
Last post2016-11-14 11:50 +0100
Articles 13 — 9 participants

Back to article view | Back to linux.debian.user


Contents

  How to run a script before shutdown? Robert Latest <boblatest@gmail.com> - 2016-11-13 20:40 +0100
    Re: How to run a script before shutdown? Sven Joachim <svenjoac@gmx.de> - 2016-11-13 21:30 +0100
      Re: How to run a script before shutdown? Robert Latest <boblatest@gmail.com> - 2016-11-14 18:50 +0100
    Re: How to run a script before shutdown? David Christensen <dpchrist@holgerdanske.com> - 2016-11-14 02:40 +0100
      Re: How to run a script before shutdown? rhkramer@gmail.com - 2016-11-14 13:40 +0100
        Re: How to run a script before shutdown? Jude DaShiell <jdashiel@panix.com> - 2016-11-14 16:30 +0100
          Re: How to run a script before shutdown? rhkramer@gmail.com - 2016-11-14 18:10 +0100
          Re: A_Message_Regarding_Your_DEBT_Situation. vs78 Jude DaShiell <jdashiel@panix.com> - 2016-11-14 22:30 +0100
            Re: A_Message_Regarding_Your_DEBT_Situation. vs78 Lisi Reisz <lisi.reisz@gmail.com> - 2016-11-14 23:20 +0100
              Re: A_Message_Regarding_Your_DEBT_Situation. vs78 Jude DaShiell <jdashiel@panix.com> - 2016-11-16 12:50 +0100
                Re: A_Message_Regarding_Your_DEBT_Situation. vs78 Tony van der Hoff <tony@vanderhoff.org> - 2016-11-16 13:00 +0100
    Re: How to run a script before shutdown? Michael Lange <klappnase@freenet.de> - 2016-11-14 11:30 +0100
      Re: How to run a script before shutdown? Hans <hans.ullrich@loop.de> - 2016-11-14 11:50 +0100

#174662 — How to run a script before shutdown?

FromRobert Latest <boblatest@gmail.com>
Date2016-11-13 20:40 +0100
SubjectHow to run a script before shutdown?
Message-ID<sD8Nb-4Dx-9@gated-at.bofh.it>
Hi all,

I want to automatically start a data backup script (to USB or network
drive) at each shutdown of my computer. I did some research into this
and found that several people have the same problem as I do. But the
threads I found petered out into discussions of several ways of doing
this, working for some people and not for others.  So here I am
wondering if there is a canonical, proper and reliable method of doing
this.

The script needs to run when a shutdown (but not a reboot) is started
while networking and USB mounts are still up, and (preferably)
multi-user mode has turned off. Perusing the systemd documentation I
found all kinds of good examples of how to start stuff in a well-ordered
manner to get the system up, but for shutting down there is quite little
information.

How is it done?

robert

[toc] | [next] | [standalone]


#174666

FromSven Joachim <svenjoac@gmx.de>
Date2016-11-13 21:30 +0100
Message-ID<sD9zz-5dF-7@gated-at.bofh.it>
In reply to#174662
On 2016-11-13 20:34 +0100, Robert Latest wrote:

> I want to automatically start a data backup script (to USB or network
> drive) at each shutdown of my computer. I did some research into this
> and found that several people have the same problem as I do. But the
> threads I found petered out into discussions of several ways of doing
> this, working for some people and not for others.  So here I am
> wondering if there is a canonical, proper and reliable method of doing
> this.
>
> The script needs to run when a shutdown (but not a reboot) is started
> while networking and USB mounts are still up, and (preferably)
> multi-user mode has turned off. Perusing the systemd documentation I
> found all kinds of good examples of how to start stuff in a well-ordered
> manner to get the system up, but for shutting down there is quite little
> information.
>
> How is it done?

There is a possible answer on superuser.com[1], scroll towards the end.

HTH,
    Sven


1. http://superuser.com/questions/1016827/how-do-i-run-a-script-before-everything-else-on-shutdown-with-systemd

[toc] | [prev] | [next] | [standalone]


#174706

FromRobert Latest <boblatest@gmail.com>
Date2016-11-14 18:50 +0100
Message-ID<sDtyh-1DM-9@gated-at.bofh.it>
In reply to#174666

[Multipart message — attachments visible in raw view] — view raw

Hi Sven,

thanks, that's 99% of what I need (I'd found that thread before but didn't
really read it all the way because it looked like discussion going
nowhere). It still needs some tweaking, though, because it runs the backup
script whenever multiuser mode is left -- no matter if it's a shutdown or
reboot. In practise this doesn't make any significant difference though.

Regards,
robert

On Sun, Nov 13, 2016 at 9:26 PM, Sven Joachim <svenjoac@gmx.de> wrote:

> On 2016-11-13 20:34 +0100, Robert Latest wrote:
>
> > I want to automatically start a data backup script (to USB or network
> > drive) at each shutdown of my computer. I did some research into this
> > and found that several people have the same problem as I do. But the
> > threads I found petered out into discussions of several ways of doing
> > this, working for some people and not for others.  So here I am
> > wondering if there is a canonical, proper and reliable method of doing
> > this.
> >
> > The script needs to run when a shutdown (but not a reboot) is started
> > while networking and USB mounts are still up, and (preferably)
> > multi-user mode has turned off. Perusing the systemd documentation I
> > found all kinds of good examples of how to start stuff in a well-ordered
> > manner to get the system up, but for shutting down there is quite little
> > information.
> >
> > How is it done?
>
> There is a possible answer on superuser.com[1], scroll towards the end.
>
> HTH,
>     Sven
>
>
> 1. http://superuser.com/questions/1016827/how-do-i-run-a-script-before-
> everything-else-on-shutdown-with-systemd
>
>

[toc] | [prev] | [next] | [standalone]


#174681

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2016-11-14 02:40 +0100
Message-ID<sDepz-8mr-19@gated-at.bofh.it>
In reply to#174662
On 11/13/2016 11:34 AM, Robert Latest wrote:
> I want to automatically start a data backup script (to USB or network
> drive) at each shutdown of my computer.

Rather than having the system call my backup/ archive scripts, I have my
backup/ archive scripts call 'shutdown' when they're done.


David

[toc] | [prev] | [next] | [standalone]


#174691

Fromrhkramer@gmail.com
Date2016-11-14 13:40 +0100
Message-ID<sDoIi-709-17@gated-at.bofh.it>
In reply to#174681
On Sunday, November 13, 2016 08:29:46 PM David Christensen wrote:
> On 11/13/2016 11:34 AM, Robert Latest wrote:
> > I want to automatically start a data backup script (to USB or network
> > drive) at each shutdown of my computer.
> 
> Rather than having the system call my backup/ archive scripts, I have my
> backup/ archive scripts call 'shutdown' when they're done.

I'm not the OP, but, wonderful idea!  And, of course, I can pass a parameter 
to my backup script--one case to shutdown after the backup, and one not to 
shutdown!

[toc] | [prev] | [next] | [standalone]


#174699

FromJude DaShiell <jdashiel@panix.com>
Date2016-11-14 16:30 +0100
Message-ID<sDrmN-hO-13@gated-at.bofh.it>
In reply to#174691
After a script starts, each command in that script runs until the script 
ends.  I noticed when doing something different with wget and wanting to 
have wget do one command then wait until a download had completed that 
without a read command somewhere in the script the next wget command 
fires off as soon as the first one runs.

On Mon, 14 Nov 2016, rhkramer@gmail.com wrote:

> Date: Mon, 14 Nov 2016 07:33:19
> From: rhkramer@gmail.com
> To: debian-user@lists.debian.org
> Subject: Re: How to run a script before shutdown?
> Resent-Date: Mon, 14 Nov 2016 12:33:40 +0000 (UTC)
> Resent-From: debian-user@lists.debian.org
> 
> On Sunday, November 13, 2016 08:29:46 PM David Christensen wrote:
>> On 11/13/2016 11:34 AM, Robert Latest wrote:
>>> I want to automatically start a data backup script (to USB or network
>>> drive) at each shutdown of my computer.
>>
>> Rather than having the system call my backup/ archive scripts, I have my
>> backup/ archive scripts call 'shutdown' when they're done.
>
> I'm not the OP, but, wonderful idea!  And, of course, I can pass a parameter
> to my backup script--one case to shutdown after the backup, and one not to
> shutdown!
>
>

-- 

[toc] | [prev] | [next] | [standalone]


#174703

Fromrhkramer@gmail.com
Date2016-11-14 18:10 +0100
Message-ID<sDsVz-1pb-27@gated-at.bofh.it>
In reply to#174699
Good point--thanks for the correction!

On Monday, November 14, 2016 10:26:04 AM Jude DaShiell wrote:
> After a script starts, each command in that script runs until the script
> ends.  I noticed when doing something different with wget and wanting to
> have wget do one command then wait until a download had completed that
> without a read command somewhere in the script the next wget command
> fires off as soon as the first one runs.
> 
> On Mon, 14 Nov 2016, rhkramer@gmail.com wrote:
> > Date: Mon, 14 Nov 2016 07:33:19
> > From: rhkramer@gmail.com
> > To: debian-user@lists.debian.org
> > Subject: Re: How to run a script before shutdown?
> > Resent-Date: Mon, 14 Nov 2016 12:33:40 +0000 (UTC)
> > Resent-From: debian-user@lists.debian.org
> > 
> > On Sunday, November 13, 2016 08:29:46 PM David Christensen wrote:
> >> On 11/13/2016 11:34 AM, Robert Latest wrote:
> >>> I want to automatically start a data backup script (to USB or network
> >>> drive) at each shutdown of my computer.
> >> 
> >> Rather than having the system call my backup/ archive scripts, I have my
> >> backup/ archive scripts call 'shutdown' when they're done.
> > 
> > I'm not the OP, but, wonderful idea!  And, of course, I can pass a
> > parameter to my backup script--one case to shutdown after the backup,
> > and one not to shutdown!

[toc] | [prev] | [next] | [standalone]


#174718 — Re: A_Message_Regarding_Your_DEBT_Situation. vs78

FromJude DaShiell <jdashiel@panix.com>
Date2016-11-14 22:30 +0100
SubjectRe: A_Message_Regarding_Your_DEBT_Situation. vs78
Message-ID<sDwZc-3Wk-25@gated-at.bofh.it>
In reply to#174699
I sent the original message about debt situation to nobody, a criminal 
harvested my email address and is using it without authorization.

On Mon, 14 Nov 2016, Janet Platupe wrote:

> Date: Mon, 14 Nov 2016 14:22:37
> From: Janet Platupe <janetp2012@gmail.com>
> To: Jude DaShiell <jdashiel@panix.com>, rhkramer@gmail.com,
>     debian-user@lists.debian.org
> Subject: Re: A_Message_Regarding_Your_DEBT_Situation. vs78
> 
> I AM NOT IN DEBT AND DO NOT OWE ANYTHING SO TO ME YOUR MESSAGE IS SPAM
>
> On Mon, Nov 14, 2016, 11:20 AM Jude DaShiell <jdashiel@panix.com> wrote:
>
>> asdg
>>
>>
>>
>>
>>
>> * Congratulation_janet: This_year,_let_GO_of_what_you_owe! Details_Inside
>> <http://go.tua.one/tuxiE>*
>>
>> ----------------------------------
>>
>> Unsubscribe <http://go.tua.one/2mZsX>
>> -----------------------------------
>> UnsubscribeTounsubscribeplaesegohereorsendmailto:
>> GRIFFIN'S_FLORAL_DESIGNS
>> POBox29502 numb:91384
>> LASVEGAS,NV 89126-9502
>> UNITEDSTATES
>>
>> ----ClickHere---- <http://go.tua.one/g7h2f>
>>
>>
>> !$@%^%&*%^*%^
>> <http://go.tua.one/tuxiE>
>

-- 

[toc] | [prev] | [next] | [standalone]


#174721 — Re: A_Message_Regarding_Your_DEBT_Situation. vs78

FromLisi Reisz <lisi.reisz@gmail.com>
Date2016-11-14 23:20 +0100
SubjectRe: A_Message_Regarding_Your_DEBT_Situation. vs78
Message-ID<sDxLz-4xB-19@gated-at.bofh.it>
In reply to#174718
On Monday 14 November 2016 21:25:55 Jude DaShiell wrote:
> I sent the original message about debt situation to nobody, a criminal
> harvested my email address and is using it without authorization.

Obviously. :-)  I didn't even get the earlier messages - they got removed as 
SPAM I imagine. :-)  Unless this one from "Janet" IS the original message and 
is the spam.  And even that didn't reach me.  Yours, Jude, is the first to do 
so.

Lisi

> On Mon, 14 Nov 2016, Janet Platupe wrote:
> > Date: Mon, 14 Nov 2016 14:22:37
> > From: Janet Platupe <janetp2012@gmail.com>
> > To: Jude DaShiell <jdashiel@panix.com>, rhkramer@gmail.com,
> >     debian-user@lists.debian.org
> > Subject: Re: A_Message_Regarding_Your_DEBT_Situation. vs78
> >
> > I AM NOT IN DEBT AND DO NOT OWE ANYTHING SO TO ME YOUR MESSAGE IS SPAM
> >
> > On Mon, Nov 14, 2016, 11:20 AM Jude DaShiell <jdashiel@panix.com> wrote:
> >> asdg
> >>
> >>
> >>
> >>
> >>
> >> * Congratulation_janet: This_year,_let_GO_of_what_you_owe!
> >> Details_Inside <http://go.tua.one/tuxiE>*
> >>
> >> ----------------------------------
> >>
> >> Unsubscribe <http://go.tua.one/2mZsX>
> >> -----------------------------------
> >> UnsubscribeTounsubscribeplaesegohereorsendmailto:
> >> GRIFFIN'S_FLORAL_DESIGNS
> >> POBox29502 numb:91384
> >> LASVEGAS,NV 89126-9502
> >> UNITEDSTATES
> >>
> >> ----ClickHere---- <http://go.tua.one/g7h2f>
> >>
> >>
> >> !$@%^%&*%^*%^
> >> <http://go.tua.one/tuxiE>

[toc] | [prev] | [next] | [standalone]


#174791 — Re: A_Message_Regarding_Your_DEBT_Situation. vs78

FromJude DaShiell <jdashiel@panix.com>
Date2016-11-16 12:50 +0100
SubjectRe: A_Message_Regarding_Your_DEBT_Situation. vs78
Message-ID<sE6T0-2eI-13@gated-at.bofh.it>
In reply to#174721
No, Janet got the message after myself I think.  In any event no real 
originating email address would appear in the chain and that's what this 
has become chain mail.

On Mon, 14 Nov 2016, Lisi Reisz wrote:

> Date: Mon, 14 Nov 2016 17:18:07
> From: Lisi Reisz <lisi.reisz@gmail.com>
> To: debian-user@lists.debian.org
> Cc: Jude DaShiell <jdashiel@panix.com>, Janet Platupe <janetp2012@gmail.com>,
>     rhkramer@gmail.com
> Subject: Re: A_Message_Regarding_Your_DEBT_Situation. vs78
> 
> On Monday 14 November 2016 21:25:55 Jude DaShiell wrote:
>> I sent the original message about debt situation to nobody, a criminal
>> harvested my email address and is using it without authorization.
>
> Obviously. :-)  I didn't even get the earlier messages - they got removed as
> SPAM I imagine. :-)  Unless this one from "Janet" IS the original message and
> is the spam.  And even that didn't reach me.  Yours, Jude, is the first to do
> so.
>
> Lisi
>
>> On Mon, 14 Nov 2016, Janet Platupe wrote:
>>> Date: Mon, 14 Nov 2016 14:22:37
>>> From: Janet Platupe <janetp2012@gmail.com>
>>> To: Jude DaShiell <jdashiel@panix.com>, rhkramer@gmail.com,
>>>     debian-user@lists.debian.org
>>> Subject: Re: A_Message_Regarding_Your_DEBT_Situation. vs78
>>>
>>> I AM NOT IN DEBT AND DO NOT OWE ANYTHING SO TO ME YOUR MESSAGE IS SPAM
>>>
>>> On Mon, Nov 14, 2016, 11:20 AM Jude DaShiell <jdashiel@panix.com> wrote:
>>>> asdg
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> * Congratulation_janet: This_year,_let_GO_of_what_you_owe!
>>>> Details_Inside <http://go.tua.one/tuxiE>*
>>>>
>>>> ----------------------------------
>>>>
>>>> Unsubscribe <http://go.tua.one/2mZsX>
>>>> -----------------------------------
>>>> UnsubscribeTounsubscribeplaesegohereorsendmailto:
>>>> GRIFFIN'S_FLORAL_DESIGNS
>>>> POBox29502 numb:91384
>>>> LASVEGAS,NV 89126-9502
>>>> UNITEDSTATES
>>>>
>>>> ----ClickHere---- <http://go.tua.one/g7h2f>
>>>>
>>>>
>>>> !$@%^%&*%^*%^
>>>> <http://go.tua.one/tuxiE>
>
>

-- 

[toc] | [prev] | [next] | [standalone]


#174792 — Re: A_Message_Regarding_Your_DEBT_Situation. vs78

FromTony van der Hoff <tony@vanderhoff.org>
Date2016-11-16 13:00 +0100
SubjectRe: A_Message_Regarding_Your_DEBT_Situation. vs78
Message-ID<sE72G-2hZ-25@gated-at.bofh.it>
In reply to#174791
On 16/11/16 11:46, Jude DaShiell wrote:

<snip>

Why the hell are people discussing obvious spam on this list? Take it 
private, or let it drop! Most of us are not interested.


-- 
Tony van der Hoff        | mailto:tony@vanderhoff.org
Buckinghamshire, England |

[toc] | [prev] | [next] | [standalone]


#174688

FromMichael Lange <klappnase@freenet.de>
Date2016-11-14 11:30 +0100
Message-ID<sDmGu-5IO-9@gated-at.bofh.it>
In reply to#174662
Hi,

On Sun, 13 Nov 2016 20:34:38 +0100
Robert Latest <boblatest@gmail.com> wrote:

> Hi all,
> 
> I want to automatically start a data backup script (to USB or network
> drive) at each shutdown of my computer. I did some research into this
> and found that several people have the same problem as I do. But the
> threads I found petered out into discussions of several ways of doing
> this, working for some people and not for others.  So here I am
> wondering if there is a canonical, proper and reliable method of doing
> this.

probably not the "canonical" way, but still works:
I have a script in /etc/init.d/mystuff for a similar task, that looks
basically like

case "$1" in
    start)
        printf "/usr/sbin/ntpdate-debian -s -b -p 8 -u de.pool.ntp.org" | at now + 2 minutes
        ;;
    stop)
        RUNL=`/sbin/runlevel`
        case ${RUNL:2:3} in 0)
            /usr/local/sbin/sys-backup;;
        esac
        ;;
esac

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Humans do claim a great deal for that particular emotion (love).
		-- Spock, "The Lights of Zetar", stardate 5725.6

[toc] | [prev] | [next] | [standalone]


#174689

FromHans <hans.ullrich@loop.de>
Date2016-11-14 11:50 +0100
Message-ID<sDmZQ-5PY-25@gated-at.bofh.it>
In reply to#174688
Maybe you might want to take a look at the package "backintime-kde"?
It may fit all your needs.

Good luck!

Hans

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web