Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #258370 > unrolled thread
| Started by | "Susmita/Rajib" <bkpsusmitaa@gmail.com> |
|---|---|
| First post | 2023-05-15 19:40 +0200 |
| Last post | 2023-05-18 08:10 +0200 |
| Articles | 20 on this page of 22 — 8 participants |
Back to article view | Back to linux.debian.user
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
Page 1 of 2 [1] 2 Next page →
| From | "Susmita/Rajib" <bkpsusmitaa@gmail.com> |
|---|---|
| Date | 2023-05-15 19:40 +0200 |
| Subject | How to run a command / script on startup automatically in linux? |
| Message-ID | <GvKkV-97s9-3@gated-at.bofh.it> |
My dear illustrious List members and leaders of the Debian-users group: I used the contents in the following webpages: https://www.tutorialspoint.com/run-a-script-on-startup-in-linux https://www.baeldung.com/linux/run-command-start-up I saved a file at "/etc/systemd/system/" named "rc-local.service" with the following lines: ------------------------------------------------ [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.local Description=Screensaver [Service] Type=forking ExecStart=/etc/rc.local start TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 ExecStart=mousepad Restart=always User=root Group=root Type=simple [Install] WantedBy=multi-user.target ------------------------------------------------ I also added the line in the file /etc/rc.local: mousepad But the program doesn't launch at startup. Where I am going wrong? Does it fail to start because the command is run before the GUI starts up? I don't want to use cron by editing crontab -e. I tried @reboot mousepad, but doesn't work. Please advise. Best wishes, Rajib B
[toc] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-05-15 19:50 +0200 |
| Message-ID | <GvKuB-97vG-3@gated-at.bofh.it> |
| In reply to | #258370 |
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). > I also added the line in the file /etc/rc.local: > mousepad Make sure /etc/rc.local is executable, and has a #!/bin/sh header line. Beyond that, I am not familiar with "mousepad". It doesn't sound like the kind of program that can be run as a background service daemon. What does it actually do? Does it interact with X11 in some way? If it does, then this is not the place to launch it. > But the program doesn't launch at startup. Where I am going wrong? > Does it fail to start because the command is run before the GUI starts > up? If it's GUI-related, then yes. You can't do this from rc.local. > I don't want to use cron by editing crontab -e. I tried @reboot > mousepad, but doesn't work. If it's GUI-related, you can't do it from crontab either. A GUI-related program has to be run after you launch your GUI session. Traditionally, this is accomplished by adding it to your .xsession file, if you wrote your own .xsession file. But most Desktop Environment users don't do that. They don't have a personal .xsession file at all. Debian created another file called .xsessionrc which you can use instead, even if your don't use an .xsession file. So, here's what I'd suggest: 1) Get rid of your /etc/systemd/system/rc-local.service file. It's not needed, and will just cause confusion. 2) Create a ~/.xsessionrc file containing the commands you want to run while starting your X session. 3) Double-check that this "mousepad" command can be run in the way you're running it. Does it self-background? If not, then you need to put an ampersand after it: mousepad & See also: https://wiki.debian.org/Xsession
[toc] | [prev] | [next] | [standalone]
| From | Charles Curley <charlescurley@charlescurley.com> |
|---|---|
| Date | 2023-05-15 20:50 +0200 |
| Subject | Re: How to run a command / script on startup automatically in linux? |
| Message-ID | <GvLqF-984M-9@gated-at.bofh.it> |
| In reply to | #258371 |
On Mon, 15 May 2023 13:42:52 -0400 Greg Wooledge <greg@wooledge.org> wrote: > There's no need to do that. Debian already ships an rc-local.service. True. In order to edit it, the user should copy it into /etc/systemd/… and edit it there. There are commands in systemd to make that fairly painless. See man systemctl -> edit. I think the OP is more interested in learning things and was following a tutorial when the question came up. But guessing what OPs are up to is a rum game. -- Does anybody read signatures any more? https://charlescurley.com https://charlescurley.com/blog/
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-05-15 21:00 +0200 |
| Message-ID | <GvLAl-988M-1@gated-at.bofh.it> |
| In reply to | #258377 |
On Mon, May 15, 2023 at 12:43:01PM -0600, Charles Curley wrote: > On Mon, 15 May 2023 13:42:52 -0400 > Greg Wooledge <greg@wooledge.org> wrote: > > > There's no need to do that. Debian already ships an rc-local.service. > > True. In order to edit it, the user should copy it into /etc/systemd/… > and edit it there. There are commands in systemd to make that fairly > painless. See man systemctl -> edit. ... why would the user want to edit it?! The unit file is already THERE, and WORKS, and does not need to be edited. > I think the OP is more interested in learning things and was following > a tutorial when the question came up. But guessing what OPs are up to > is a rum game. I'm fairly certain the OP wants to run this "mousepad" program automatically as part of their X or Wayland session. If they're using a Wayland session, then I cannot offer any help. If they're using X, then my previous message contains all that's needed, for someone who can follow the instructions. Conceptually, the main hurdle here is that the OP did not seem to understand that these are two entirely separate things: 1) System startup. 2) User session startup. (And 2a, user GUI session startup, which may be a separate step.) An X11 program has to be started as part of the latter. Their original attempt was trying to incorporate it into the former, which is not going to work.
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2023-05-16 06:30 +0200 |
| Message-ID | <GvUtX-9dOv-1@gated-at.bofh.it> |
| In reply to | #258380 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, May 15, 2023 at 02:51:10PM -0400, Greg Wooledge wrote: [...] > I'm fairly certain the OP wants to run this "mousepad" program > automatically as part of their X or Wayland session. [...] This is my take, too. Cheers -- t
[toc] | [prev] | [next] | [standalone]
| From | Vincent Lefevre <vincent@vinc17.net> |
|---|---|
| Date | 2023-05-15 21:40 +0200 |
| Message-ID | <GvMd3-98Be-1@gated-at.bofh.it> |
| In reply to | #258371 |
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. > A GUI-related program has to be run after you launch your GUI session. > Traditionally, this is accomplished by adding it to your .xsession file, > if you wrote your own .xsession file. But most Desktop Environment > users don't do that. They don't have a personal .xsession file at all. The .xsession file entirely replaces the desktop environment or window manager. See /etc/X11/Xsession.d/50x11-common_determine-startup and the Xsession(5) man page. This is useful to run configuration utilities before explicitly running the window manager at the end. > Debian created another file called .xsessionrc which you can use instead, > even if your don't use an .xsession file. But note that programs run from .xsessionrc may be run too soon (before other settings from /etc/X11/Xsession.d). The .xsessionrc file should only be used to set up environment variables and things like that. > So, here's what I'd suggest: > > 1) Get rid of your /etc/systemd/system/rc-local.service file. It's not > needed, and will just cause confusion. Agreed. > 2) Create a ~/.xsessionrc file containing the commands you want to run > while starting your X session. This depends on the commands. GUI applications like mousepad should not be run from it. They should be run by the DE or WM. If this is not possible, run them just before via a ".xsession" file. > 3) Double-check that this "mousepad" command can be run in the way you're > running it. Does it self-background? If not, then you need to put > an ampersand after it: > > mousepad & Note that if it is run by the DE or WM (recommended way as this may benefit from the DE/WM features), there is probably no need for the "&". > See also: https://wiki.debian.org/Xsession The man page is more detailed. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-05-15 22:00 +0200 |
| Message-ID | <GvMwp-98HY-3@gated-at.bofh.it> |
| In reply to | #258384 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Vincent Lefevre <vincent@vinc17.net> |
|---|---|
| Date | 2023-05-15 23:10 +0200 |
| Message-ID | <GvNC9-99A8-13@gated-at.bofh.it> |
| In reply to | #258388 |
On 2023-05-15 15:56:17 -0400, Greg Wooledge wrote: > 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. It is correct, as shown by the following command: zira:~> dlocate etc/rc.local initscripts: /etc/rc.local Ditto with "apt-file search etc/rc.local". > You can claim that using rc.local is a bad practice, This is not what I'm saying. I'm saying that using it in a way that it incompatible with initscripts (which provides the file) is a bad idea. Note that the user might want to install later a package that would depend on it, and things could break in obscure ways. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2023-05-16 06:40 +0200 |
| Subject | Editing /etc/rc.local [was: How to run a command / script on startup automatically in linux?] |
| Message-ID | <GvUDD-9dRT-1@gated-at.bofh.it> |
| In reply to | #258396 |
[Multipart message — attachments visible in raw view] — view raw
Changed $SUBJECT, because already way off track. On Mon, May 15, 2023 at 11:05:07PM +0200, Vincent Lefevre wrote: > On 2023-05-15 15:56:17 -0400, Greg Wooledge wrote: [editing /etc/rc.local is a bad idea] > > That's incorrect. > > It is correct, as shown by the following command: > > zira:~> dlocate etc/rc.local > initscripts: /etc/rc.local > > Ditto with "apt-file search etc/rc.local". I'm with Greg here. /etc/rc.local is package-provided, but it is a conffile [1], [2]: tomas@trotzki:~$ dpkg --status initscripts Package: initscripts Status: install ok installed Priority: optional [...] Conffiles: /etc/default/devpts 725336081392e54776899acd2bff6e39 [...] /etc/rc.local 12fe1992accd3a3977b4d8985ebeea9e [...] It's there for you, the system administrator to edit and change. The packaging system is explicitly designed to cope with that situation (technically it keeps a fingerprint of the pristine file and checks that on updates giving you, the sysadmin, the chance to forward-port your changes). Cheers [1] https://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles [2] https://raphaelhertzog.com/2010/09/21/debian-conffile-configuration-file-managed-by-dpkg/ -- tomás
[toc] | [prev] | [next] | [standalone]
| From | Vincent Lefevre <vincent@vinc17.net> |
|---|---|
| Date | 2023-05-16 11:50 +0200 |
| Subject | Re: Editing /etc/rc.local [was: How to run a command / script on startup automatically in linux?] |
| Message-ID | <GvZtD-9hhh-11@gated-at.bofh.it> |
| In reply to | #258407 |
On 2023-05-16 06:36:34 +0200, tomas@tuxteam.de wrote: > On Mon, May 15, 2023 at 11:05:07PM +0200, Vincent Lefevre wrote: > > On 2023-05-15 15:56:17 -0400, Greg Wooledge wrote: > > [editing /etc/rc.local is a bad idea] No, entirely *replacing* /etc/rc.local is a bad idea. > > > That's incorrect. > > > > It is correct, as shown by the following command: > > > > zira:~> dlocate etc/rc.local > > initscripts: /etc/rc.local > > > > Ditto with "apt-file search etc/rc.local". > > I'm with Greg here. /etc/rc.local is package-provided, but it is > a conffile [1], [2]: > > tomas@trotzki:~$ dpkg --status initscripts > Package: initscripts > Status: install ok installed > Priority: optional > [...] > Conffiles: > /etc/default/devpts 725336081392e54776899acd2bff6e39 > [...] > /etc/rc.local 12fe1992accd3a3977b4d8985ebeea9e > [...] > > It's there for you, the system administrator to edit and change. > The packaging system is explicitly designed to cope with that > situation (technically it keeps a fingerprint of the pristine > file and checks that on updates giving you, the sysadmin, the > chance to forward-port your changes). Yes, this is *allowed*. But you should not recommend that to users without knowing the possible consequences on their machines. This is not because it a conffile that you can do anything with it without breaking parts of the system. -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
[toc] | [prev] | [next] | [standalone]
| From | Charles Curley <charlescurley@charlescurley.com> |
|---|---|
| Date | 2023-05-15 20:00 +0200 |
| Subject | Re: How to run a command / script on startup automatically in linux? |
| Message-ID | <GvKEh-97ze-11@gated-at.bofh.it> |
| In reply to | #258370 |
On Mon, 15 May 2023 22:44:37 +0530 "Susmita/Rajib" <bkpsusmitaa@gmail.com> wrote: > ExecStart=/etc/rc.local start > TimeoutSec=0 > StandardOutput=tty > RemainAfterExit=yes > SysVStartPriority=99 > ExecStart=mousepad The fact that you have two ExecStart lines in there might have something to do with it. The exercise was to show you how to use /etc/rc.local, so I would suggest you use the systemd file exactly as they showed it, and put a call to mousepad into /etc/rc.local. You may have to create it. If so, be sure to make it owned by root:root and execute for the owner only. Exactly how you do those things I leave as an exercise for the student. However, the systemd service is the better approach, so I suggest you play with that approach and create a mousepad service. Good luck. -- Does anybody read signatures any more? https://charlescurley.com https://charlescurley.com/blog/
[toc] | [prev] | [next] | [standalone]
| From | Max Nikulin <manikulin@gmail.com> |
|---|---|
| Date | 2023-05-16 04:40 +0200 |
| Message-ID | <GvSLv-9cDu-1@gated-at.bofh.it> |
| In reply to | #258372 |
On 16/05/2023 00:54, Charles Curley wrote:
> On Mon, 15 May 2023 22:44:37 +0530
> "Susmita/Rajib" wrote:
>
>> ExecStart=/etc/rc.local start
>> TimeoutSec=0
>> StandardOutput=tty
>> RemainAfterExit=yes
>> SysVStartPriority=99
>> ExecStart=mousepad
>
> The fact that you have two ExecStart lines in there might have
> something to do with it.
Charles, ExecStart commands are accumulated, see systemd.service(5). To
clear earlier specified value (e.g. in an override config snippet) use
the directive with no command
ExecStart=
Back to the original topic. Anyway it was a bad idea to abuse
rc-local.service. Unless it was a GUI application, it would be better to
create a new .service to be able start, check status, disable the unit
independently.
For mousepad, keywords are most likely "XDG autostart". "No DE" users
usually aware what file should be edited for their window managers.
[toc] | [prev] | [next] | [standalone]
| From | Max Nikulin <manikulin@gmail.com> |
|---|---|
| Date | 2023-05-16 09:10 +0200 |
| Message-ID | <GvWYN-9fWm-7@gated-at.bofh.it> |
| In reply to | #258404 |
On 16/05/2023 09:32, Max Nikulin wrote: > For mousepad, keywords are most likely "XDG autostart". E.g. Emacs provides emacs.service for *user* systemd sessions (~/.config/systemd/user, systemctl --user), not system ones. However I am still in doubts if such approach should be applied to mousepad. Autostart should work in LXDE.
[toc] | [prev] | [next] | [standalone]
| From | Christoph Brinkhaus <c.brinkhaus@t-online.de> |
|---|---|
| Date | 2023-05-15 20:10 +0200 |
| Message-ID | <GvKNX-97RJ-1@gated-at.bofh.it> |
| In reply to | #258370 |
[Multipart message — attachments visible in raw view] — view raw
Am Mon, May 15, 2023 at 10:44:37PM +0530 schrieb Susmita/Rajib: Hello Rajib, > My dear illustrious List members and leaders of the Debian-users group: > I used the contents in the following webpages: > https://www.tutorialspoint.com/run-a-script-on-startup-in-linux > https://www.baeldung.com/linux/run-command-start-up > > I saved a file at "/etc/systemd/system/" named "rc-local.service" with > the following lines: > ------------------------------------------------ > [Unit] > Description=/etc/rc.local Compatibility > ConditionPathExists=/etc/rc.local > Description=Screensaver > > [Service] > Type=forking > ExecStart=/etc/rc.local start > TimeoutSec=0 > StandardOutput=tty > RemainAfterExit=yes > SysVStartPriority=99 > ExecStart=mousepad > Restart=always > User=root > Group=root > Type=simple > > [Install] > WantedBy=multi-user.target > ------------------------------------------------ > > I also added the line in the file /etc/rc.local: > mousepad > > But the program doesn't launch at startup. Where I am going wrong? > Does it fail to start because the command is run before the GUI starts > up? > > I don't want to use cron by editing crontab -e. I tried @reboot > mousepad, but doesn't work. > > Please advise. Have you already enabled your script with the systemd command? This is from the first link you have provided: Enable the service by running the following command "sudo systemctl enable yourscriptname.service" Start the service by running the following command "sudo systemctl start yourscriptname.service" If the service enabled and started please check the output of systemctl --failed. The command systemctl status yourscriptname.service should give information even if the service is running. Kind regards, Christoph -- Ist die Katze gesund schmeckt sie dem Hund.
[toc] | [prev] | [next] | [standalone]
| From | <tomas@tuxteam.de> |
|---|---|
| Date | 2023-05-15 20:30 +0200 |
| Message-ID | <GvL7j-97Y8-3@gated-at.bofh.it> |
| In reply to | #258370 |
[Multipart message — attachments visible in raw view] — view raw
On Mon, May 15, 2023 at 10:44:37PM +0530, Susmita/Rajib wrote:
> My dear illustrious List members and leaders of the Debian-users group:
[...]
> I saved a file at "/etc/systemd/system/" named "rc-local.service" with
> the following lines:
[...]
> I also added the line in the file /etc/rc.local:
> mousepad
Is it this mousepad?
mousepad/stable 0.5.2-1 amd64
simple Xfce oriented text editor
> But the program doesn't launch at startup. Where I am going wrong?
> Does it fail to start because the command is run before the GUI starts
> up?
Then yes: system startup is "too early". Most probably you don't even
want to have it running as a "system program", but as a "user program",
under your user ID and whithin your (user) graphical session.
In this case, I'd look at what possibilities your desktop environment
(or window manager) offer. They usually have a way to start programs
at session start (at which point all the environment your mousepad will
need is set up).
> I don't want to use cron by editing crontab -e. I tried @reboot
> mousepad, but doesn't work.
Again: cron is "outside" the graphical environment. If my hunch above
is correct, it will feel "lost" and won't even know how to start.
So please tell us two things:
- what is this "mousepad" thing?
- what desktop environment/window manager are you using?
Cheers
--
tomás
[toc] | [prev] | [next] | [standalone]
| From | Charles Curley <charlescurley@charlescurley.com> |
|---|---|
| Date | 2023-05-15 20:50 +0200 |
| Subject | Re: How to run a command / script on startup automatically in linux? |
| Message-ID | <GvLqF-984M-11@gated-at.bofh.it> |
| In reply to | #258375 |
On Mon, 15 May 2023 20:26:09 +0200 <tomas@tuxteam.de> wrote: > Is it this mousepad? > > mousepad/stable 0.5.2-1 amd64 > simple Xfce oriented text editor > > > But the program doesn't launch at startup. Where I am going wrong? > > Does it fail to start because the command is run before the GUI > > starts up? > > Then yes: system startup is "too early". Most probably you don't even > want to have it running as a "system program", but as a "user > program", under your user ID and whithin your (user) graphical > session. > > In this case, I'd look at what possibilities your desktop environment > (or window manager) offer. They usually have a way to start programs > at session start (at which point all the environment your mousepad > will need is set up). Right. If it is that mousepad, and if the OP is running XFCE, he can probably add it to XFCE's session manager. Applications -> Settings -> Session and Startup -> Application Autostart. -- Does anybody read signatures any more? https://charlescurley.com https://charlescurley.com/blog/
[toc] | [prev] | [next] | [standalone]
| From | Joe <joe@jretrading.com> |
|---|---|
| Date | 2023-05-15 21:40 +0200 |
| Subject | Re: How to run a command / script on startup automatically in linux? |
| Message-ID | <GvMd3-98Be-13@gated-at.bofh.it> |
| In reply to | #258375 |
On Mon, 15 May 2023 20:26:09 +0200 <tomas@tuxteam.de> wrote: > On Mon, May 15, 2023 at 10:44:37PM +0530, Susmita/Rajib wrote: > > My dear illustrious List members and leaders of the Debian-users > > group: > > [...] > > > I saved a file at "/etc/systemd/system/" named "rc-local.service" > > with the following lines: > > [...] > > > I also added the line in the file /etc/rc.local: > > mousepad > > > Is it this mousepad? > > mousepad/stable 0.5.2-1 amd64 > simple Xfce oriented text editor That's the only one I ever heard of. I use it, mostly as a clipboard where the usual copy/paste is having trouble, or if I want to make alterations before pasting. > > > But the program doesn't launch at startup. Where I am going wrong? > > Does it fail to start because the command is run before the GUI > > starts up? > > Then yes: system startup is "too early". Most probably you don't even > want to have it running as a "system program", but as a "user > program", under your user ID and whithin your (user) graphical > session. > > In this case, I'd look at what possibilities your desktop environment > (or window manager) offer. They usually have a way to start programs > at session start (at which point all the environment your mousepad > will need is set up). Indeed. If the OP is running Xfce, then Settings, Session and Startup in the main menu allow applications to be started on login. But this is the simple answer, and it may be that the OP is more concerned with learning system autostart procedures, in which case a GUI application like Mousepad isn't the right one to play with. Running something like an iptables script without using iptables-persistent might be a better choice. -- Joe
[toc] | [prev] | [next] | [standalone]
| From | "Susmita/Rajib" <bkpsusmitaa@gmail.com> |
|---|---|
| Date | 2023-05-16 07:50 +0200 |
| Message-ID | <GvVJn-9eWR-1@gated-at.bofh.it> |
| In reply to | #258370 |
From: Greg Wooledge <greg@wooledge.org> Date: Mon, 15 May 2023 13:42:52 -0400 Message-id: <[🔎] ZGJvHOPhrPRyMiP3@wooledge.org> Date: Mon, 15 May 2023 21:37:29 +0200 Message-id: <[🔎] 20230515193729.GO1694795@zira.vinc17.org> Mail-followup-to: debian-user@lists.debian.org From: Christoph Brinkhaus <c.brinkhaus@t-online.de> Date: Mon, 15 May 2023 20:06:49 +0200 Message-id: <[🔎] ZGJ0uYgwoLWV8GMw@lenovo.local> From: <tomas@tuxteam.de> Date: Mon, 15 May 2023 20:26:09 +0200 Message-id: <[🔎] ZGJ5Qen53mxBo6Xi@tuxteam.de> From: Joe <joe@jretrading.com> Date: Mon, 15 May 2023 20:30:56 +0100 Message-id: <[🔎] 20230515203056.47030676@jrenewsid.jretrading.com> Thank you, leaders, for posting your replies to my post. I admire your intent to support a perpetual novice. Please once more check the two links that I had posted on the OP. If I want to run a script named script.sh how should I set my system up, like what should the supporting files look like, based on the OP? What would the supporting files look like, if I wanted to run mousepad, a GUI program, after lxsession begins? [To Mr. Wooledge]: Dear Mr. Wooledge, I thank you for your two replies. The essence has been noted: "... Create a ~/.xsessionrc file ... starting your X session. ..." Please inform as to where should I create this file. You also said: "... "mousepad" command ... Does it (mousepad) self-background? ... mousepad & ..." Does self-background mean that if I click on another program, it automatically runs in the background? In that case, yes it does. Mousepad is a plain text editor like the earlier leafpad. Other leaders have already informed you. And yes, you have summarised succinctly when you separately said, " ... I'm fairly certain the OP wants to run this "mousepad" program automatically as part of their X or Wayland session. ..." and "... OP's implied goal of running an X11 client program at user login. ..." [To Mr. Charlie]: Dear Mr. Charlie, Thank you, Mr. Charlie, for your post. But I am afraid that I can't agree to your comment, "... I think the OP is more interested in learning things and was following a tutorial when the question came up. ..." Actually, I am trying to fulfil an objective. [To Mr. Lefèvre]: Dear Mr. Lefèvre, Thank you for posting your comments. I have noted your lines, particularly, "... The /etc/rc.local file is provided by the initscripts package. I would suggest to either install this package ..." Yes, I have checked that if I go to Alt+Ctrl+F1 (or F2,3,4, etc) and type init 3 the lxsession isn't killed. I can kill by the kill -9 `pidof ...` command. Then I can't get back to init 5 (runlevel5) by simply typing. Some changes have happened over many releases. You also mentioned, "... GUI applications like mousepad should not be run from it. They should be run by the DE or WM. If this is not possible, run them just before via a ".xsession" file ..." WM is windows manager. DE is Desktop Environment. For those who will read this post later on, a compact explanation is at https://askubuntu.com/questions/18078/what-is-the-difference-between-a-desktop-environment-and-a-window-manager Thank you, Mr. Lefèvre, for your inputs. Your amended input for your lines, "... he can probably add it to XFCE's session manager. Applications -> Settings -> Session and Startup -> Application Autostart. ..." [To Mr. Tomas]: Dear Mr. Tomas, Thank you, Mr. Tomas, for your inputs. Yes, you are absolutely right about the mousepad program that I am using. I just want to have the mousepad automatically launched whenever I begin my GUI session. [To Mr. Brinkhaus]: Dear Mr. Brinkhaus, Thank you for your input. But owing to the situation clarified by the comments received and summarised above, I will for the time being pause my endeavour with systemd command. But I will get back to you for your input and advice, particularly on "... Have you already enabled your script with the systemd command? This is from the first link you have provided: Enable the service by running the following command "sudo systemctl enable yourscriptname.service" Start the service by running the following command "sudo systemctl start yourscriptname.service" If the service enabled and started please check the output of systemctl --failed. The command systemctl status yourscriptname.service should give information even if the service is running. ..." [To Mr. Joe]: Dear Mr. Joe, Thank you for your reply to Mr. Tomas with a little change: I use the Debian lxde session, having it installed from the Official Debian GNU/Linux Live 11.6.0 lxde 2022-12-17T11:46. So to my tentative next step: Following Mr. Wooledge's advice, I would "... Create a ~/.xsessionrc file ... starting your X session. ..." A little more tutiion on this, Mr. Wooledge please. Any advice on this, Mr. Lefèvre, particularly, on autostarting applications? Leaders, any advice on this? Also supposing that I would use my screensaver based on "xset dpms force off" at the start of the lxsession, what would be my steps? How should I proceed if I want to automatically have claws-mail or mousepad running when a new lxsession is begun? Thanks and best wishes, Rajib
[toc] | [prev] | [next] | [standalone]
| From | Vincent Lefevre <vincent@vinc17.net> |
|---|---|
| Date | 2023-05-16 12:10 +0200 |
| Message-ID | <GvZN0-9hD6-3@gated-at.bofh.it> |
| In reply to | #258408 |
On 2023-05-16 10:54:05 +0530, Susmita/Rajib wrote: [...] > So to my tentative next step: > Following Mr. Wooledge's advice, I would "... Create a ~/.xsessionrc > file ... starting your X session. ..." A little more tutiion on this, > Mr. Wooledge please. In your case, you should not use the ~/.xsessionrc file to start a GUI program. > Any advice on this, Mr. Lefèvre, particularly, on autostarting > applications? Since you mentioned lxsession, I suppose that you're using LXDE. I don't know it, but it already has some "autostart" feature, so this is what you should use. There's some documentation about LXDE's autostart there, and I suppose that this is the same for Debian: https://wiki.archlinux.org/title/LXDE > Also supposing that I would use my screensaver based on "xset dpms > force off" at the start of the lxsession, what would be my steps? I don't know the recommended way for LXDE, but autostart may also be a possibility. > How should I proceed if I want to automatically have claws-mail or > mousepad running when a new lxsession is begun? So, in short, ~/.config/lxsession/LXDE/autostart would contain @xset dpms force off @mousepad @claws-mail -- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
[toc] | [prev] | [next] | [standalone]
| From | Greg Wooledge <greg@wooledge.org> |
|---|---|
| Date | 2023-05-16 13:20 +0200 |
| Message-ID | <Gw0SK-9ieC-3@gated-at.bofh.it> |
| In reply to | #258408 |
On Tue, May 16, 2023 at 10:54:05AM +0530, Susmita/Rajib wrote: > Please once more check the two links that I had posted on the OP. If I > want to run a script named script.sh how should I set my system up, > like what should the supporting files look like, based on the OP? Without knowing what this "script.sh" does, and how your system is configured (which init system, etc.) it's impossible to answer this question. There are too many possible answers. Is it network-related? Then maybe it should be run when an interface is brought up. Or maybe not! Maybe you should write a systemd unit file for it. Or maybe your system isn't running systemd at all. In that case, do you write a legacy init.d script? Or write a run script for some other init system? Or do you just drop a few lines of shell code in rc.local? Is it an end user application? Then it probably belongs in a user's login configuration. Unless it's a GRAPHICAL end user application, in which case it probably belongs in a GUI session's configuration. Or maybe it's a daemon that's supposed to support an end user's overall session, in which case maybe a systemd --user unit file is appropriate. Again, unless your system doesn't run systemd, in which case an entirely different approach is needed. And so on.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.debian.user
csiph-web