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


Groups > linux.debian.user > #258388

Re: How to run a command / script on startup automatically in linux?

From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: How to run a command / script on startup automatically in linux?
Date 2023-05-15 22:00 +0200
Message-ID <GvMwp-98HY-3@gated-at.bofh.it> (permalink)
References <GvKkV-97s9-3@gated-at.bofh.it> <GvKuB-97vG-3@gated-at.bofh.it> <GvMd3-98Be-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, May 15, 2023 at 09:37:29PM +0200, Vincent Lefevre wrote:
> On 2023-05-15 13:42:52 -0400, Greg Wooledge wrote:
> > On Mon, May 15, 2023 at 10:44:37PM +0530, Susmita/Rajib wrote:
> > > 
> > > I saved a file at "/etc/systemd/system/" named "rc-local.service" with
> > > the following lines:
> > > ------------------------------------------------
> > 
> > There's no need to do that.  Debian already ships an rc-local.service.
> > 
> > All you need to do is create an /etc/rc.local file, make it executable,
> > and make sure it's a valid shell script (with a shebang and all that).
> 
> This is a bad idea. The /etc/rc.local file is provided by the
> initscripts package. I would suggest to either install this
> package and use it in the way it is intended or create your
> own service.

That's incorrect.

===========================================================================
unicorn:~$ systemctl cat rc-local.service | cat
# /lib/systemd/system/rc-local.service
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

# /lib/systemd/system/rc-local.service.d/debian.conf
[Unit]
# not specified by LSB, but has been behaving that way in Debian under SysV
# init and upstart
After=network-online.target

# Often contains status messages which users expect to see on the console
# during boot
[Service]
StandardOutput=journal+console
StandardError=journal+console
===========================================================================

You can claim that using rc.local is a bad practice, and I won't argue
against you.  But this unit *is* provided by Debian (including Debian's
own little patch, which you can see at the end of the output above), and
if you want to use rc.local at all, this is how it's done.

Of course, this is all irrelevant to the OP's implied goal of running
an X11 client program at user login.

Back to linux.debian.user | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to run a command / script on startup automatically in linux? "Susmita/Rajib" <bkpsusmitaa@gmail.com> - 2023-05-15 19:40 +0200
  Re: How to run a command / script on startup automatically in linux? Greg Wooledge <greg@wooledge.org> - 2023-05-15 19:50 +0200
    Re: How to run a command / script on startup automatically in  linux? Charles Curley <charlescurley@charlescurley.com> - 2023-05-15 20:50 +0200
      Re: How to run a command / script on startup automatically in linux? Greg Wooledge <greg@wooledge.org> - 2023-05-15 21:00 +0200
        Re: How to run a command / script on startup automatically in linux? <tomas@tuxteam.de> - 2023-05-16 06:30 +0200
    Re: How to run a command / script on startup automatically in linux? Vincent Lefevre <vincent@vinc17.net> - 2023-05-15 21:40 +0200
      Re: How to run a command / script on startup automatically in linux? Greg Wooledge <greg@wooledge.org> - 2023-05-15 22:00 +0200
        Re: How to run a command / script on startup automatically in linux? Vincent Lefevre <vincent@vinc17.net> - 2023-05-15 23:10 +0200
          Editing /etc/rc.local [was: How to run a command / script on startup  automatically in linux?] <tomas@tuxteam.de> - 2023-05-16 06:40 +0200
            Re: Editing /etc/rc.local [was: How to run a command / script on  startup automatically in linux?] Vincent Lefevre <vincent@vinc17.net> - 2023-05-16 11:50 +0200
  Re: How to run a command / script on startup automatically in  linux? Charles Curley <charlescurley@charlescurley.com> - 2023-05-15 20:00 +0200
    Re: How to run a command / script on startup automatically in linux? Max Nikulin <manikulin@gmail.com> - 2023-05-16 04:40 +0200
      Re: How to run a command / script on startup automatically in linux? Max Nikulin <manikulin@gmail.com> - 2023-05-16 09:10 +0200
  Re: How to run a command / script on startup automatically in linux? Christoph Brinkhaus <c.brinkhaus@t-online.de> - 2023-05-15 20:10 +0200
  Re: How to run a command / script on startup automatically in linux? <tomas@tuxteam.de> - 2023-05-15 20:30 +0200
    Re: How to run a command / script on startup automatically in  linux? Charles Curley <charlescurley@charlescurley.com> - 2023-05-15 20:50 +0200
    Re: How to run a command / script on startup automatically in  linux? Joe <joe@jretrading.com> - 2023-05-15 21:40 +0200
  Re: How to run a command / script on startup automatically in linux? "Susmita/Rajib" <bkpsusmitaa@gmail.com> - 2023-05-16 07:50 +0200
    Re: How to run a command / script on startup automatically in linux? Vincent Lefevre <vincent@vinc17.net> - 2023-05-16 12:10 +0200
    Re: How to run a command / script on startup automatically in linux? Greg Wooledge <greg@wooledge.org> - 2023-05-16 13:20 +0200
    Re: How to run a command / script on startup automatically in linux? "Susmita/Rajib" <bkpsusmitaa@gmail.com> - 2023-05-16 14:10 +0200
      Re: How to run a command / script on startup automatically in linux? "Susmita/Rajib" <bkpsusmitaa@gmail.com> - 2023-05-18 08:10 +0200

csiph-web