How to restart a systemctl service from within the process

Colin Law clanlaw at gmail.com
Mon Nov 23 12:30:04 UTC 2020


On Mon, 23 Nov 2020 at 12:12, Chris Green <cl at isbd.net> wrote:
>
> On Mon, Nov 23, 2020 at 10:33:54AM +0000, Colin Law wrote:
> > On Mon, 23 Nov 2020 at 10:08, Chris Green <cl at isbd.net> wrote:
> > >
> > > On Mon, Nov 23, 2020 at 09:21:54AM +0000, Colin Law wrote:
> > > > On Sun, 22 Nov 2020 at 15:50, Chris Green <cl at isbd.net> wrote:
> > > > >
> > > > > You can have user processes run and handled by systemctl.
> > > >
> > > > Does that mean that if I have a service running as a particular user
> > > > that the user can 'systemctl restart' it without using sudo?
> > > > Searching hasn't found anything relevant, likely because I am not
> > > > using the right search terms.
> > > >
> > > Yes. I run syncthing using systemd.
> >
> > Sorry, we are at cross purposes I think.  I am aware that a service
> > can be run as a user (I am doing that already), the question is
> > whether that user can somehow run 'systemctl restart' to restart it
> > without having to use sudo.  It is arguable that that should be
> > possible, since it is his process.
> >
>
> "systemctl restart syncthing at chris.service"

Should that be

systemctl --user restart syncthing at chris.service

But my service is not called nodered at me.service, it is nodered.service

Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html

[Service]
Type=simple
User=me
Group=me
WorkingDirectory=/home/me

Nice=5
Environment="NODE_OPTIONS=--max_old_space_size=512"
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
# Use SIGINT to stop
KillSignal=SIGINT
# Auto restart on crash
Restart=on-failure
# Tag things in the log
SyslogIdentifier=Node-RED

[Install]
WantedBy=multi-user.target

Colin




More information about the ubuntu-users mailing list