mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Linux

Reply
 
Thread Tools
Old 2022-07-31, 13:58   #1
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

2·5·7·73 Posts
Default Debian Buster Start Script at Boot

I've been lots of places on the web and tried both cron and creating a service in multiple manners, all without success. Can someone point me toward a procedure that works?

I basically would like a terminal to visibly run a bash script when the computer is powered up.
EdH is offline   Reply With Quote
Old 2022-07-31, 18:51   #2
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

437910 Posts
Default

I think you need to use screen as a @reboot cron job.

Details somebody please.
paulunderwood is offline   Reply With Quote
Old 2022-07-31, 19:41   #3
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

117668 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
I think you need to use screen as a @reboot cron job.

Details somebody please.
My trouble with crontab was (and still is) that @reboot does absolutely nothing. No matter what I try to have happen @reboot doesn't run.*

Thanks for a new idea, though! I shall explore using a service with tmux first, since I'm already using that regularly and somewhere I read that screen is deprecated, at least in some linux packages.

* I read somewhere that having both cron and anacron could cause this, but I have only cron.
EdH is offline   Reply With Quote
Old 2022-07-31, 21:22   #4
pepi37
 
pepi37's Avatar
 
Dec 2011
After milion nines:)

64716 Posts
Default

I make command (example)
Quote:
cd root
cd GFN1
sh 1
lets say that command is named a.sh and would like to start when machine is up/rebooted
in crontab I add line (crontab -e)
Quote:
@reboot a.sh
put cursor in new line, save it.
On exit crontab write new job added ( or something like that)


Now I see this is not what you need :(

Last fiddled with by pepi37 on 2022-07-31 at 21:24
pepi37 is offline   Reply With Quote
Old 2022-08-01, 05:10   #5
axn
 
axn's Avatar
 
Jun 2003

34×67 Posts
Default

Quote:
Originally Posted by EdH View Post
My trouble with crontab was (and still is) that @reboot does absolutely nothing. No matter what I try to have happen @reboot doesn't run.*
Do you use sudo crontab for @reboot? I have it, and it works fine.
axn is offline   Reply With Quote
Old 2022-08-01, 16:18   #6
chris2be8
 
chris2be8's Avatar
 
Sep 2009

3·11·73 Posts
Default

Do you mean *before* or *after* you log on to the computer?
What ID should the script run as?
What terminal emulator are you using?

To run as yourself after logging on call it from .bashrc (or .profile). I've not tested this but qterminal -e myscript.sh & should start myscript.sh running in a terminal (this assumes you have qterminal installed). Check the man page for whatever terminal emulator you have for other options. You might need nohup to keep it running after .bashrc has ended.

I've no idea how to get a script running in a window before you log on though. I don't think the GUI would be set up to show multiple windows then.
chris2be8 is offline   Reply With Quote
Old 2022-08-01, 17:00   #7
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

2×5×7×73 Posts
Default

To answer some questions:

Although I am using the root crontab to shut the machine down in the evening, I was attempting this with the user's crontab. I didn't consider trying @reboot in the root crontab. I will explore that.

My preference would be gnome-terminal, which I use everywhere across all my machines, but I only have three Debian systems and they already have some different things from the rest, so an alternate terminal wouldn't be too bad. But, I don't think the terminal choice has any bearing on the issue at hand, does it?

I'm trying to get a script to run when the system powers up and the math userid becomes active, with a visible terminal existing in the GUI when I bring it up remotely via an SSH VNC session, since these machines are headless. I do have a script that runs a gnome-terminal that in turn runs the script I'm ultimately interested in. The issue is just getting it to run when it is powered up.

From what I've read, systemd is the current preferred method to add startup scripts, and that would be fine, if it would work, but none of the examples do. I also wouldn't mind using crontab, if that would work on powerup.

As a last thought, many of the pages I've used for my trials change file attributes via chmod calls, including some making the scripts executable, while others do not. Maybe within all my play, I have those attributes all confused and really need to start fresh by deleting a bunch of things first.

Thanks everyone for trying to help me iron this out.
EdH is offline   Reply With Quote
Old 2022-08-02, 11:26   #8
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

111B16 Posts
Default

Quote:
Originally Posted by EdH View Post

I'm trying to get a script to run when the system powers up and the math userid becomes active, with a visible terminal existing in the GUI when I bring it up remotely via an SSH VNC session, since these machines are headless. I do have a script that runs a gnome-terminal that in turn runs the script I'm ultimately interested in. The issue is just getting it to run when it is powered up.
I see this as two problems: Firstly getting something to run at boot and secondly getting something to run when logging in.

For the first use @reboot su math-user -c "X" (in sudo crontab -e) where X is uses the screen command to run your program.

Secondly, use the xterm command (or whatever) with the screen command again to see the status of your process. This command string can be put into your .bashrc file on the target machine.

Last fiddled with by paulunderwood on 2022-08-02 at 11:31
paulunderwood is offline   Reply With Quote
Old 2022-08-03, 19:29   #9
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

2·5·7·73 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
I see this as two problems: Firstly getting something to run at boot and secondly getting something to run when logging in.

For the first use @reboot su math-user -c "X" (in sudo crontab -e) where X is uses the screen command to run your program.

Secondly, use the xterm command (or whatever) with the screen command again to see the status of your process. This command string can be put into your .bashrc file on the target machine.
I tried all kinds of variations in the root crontab file, with no success. I did have success in making sure @reboot does something by having it create a file. (I didn't try that in the user crontab yet.) I did install screen since that's where everyone is pointing me. Both screen and tmux run using the command I'm adding to the root crontab, but neither work from @reboot.

As to the second, I'm not familiar with .bashrc, but doesn't that just affect the behavior of bash when run? I'm guessing the first needs to work before the second is useful.
EdH is offline   Reply With Quote
Old 2022-08-03, 22:31   #10
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

437910 Posts
Default

Quote:
Originally Posted by EdH View Post
I tried all kinds of variations in the root crontab file, with no success. I did have success in making sure @reboot does something by having it create a file. (I didn't try that in the user crontab yet.) I did install screen since that's where everyone is pointing me. Both screen and tmux run using the command I'm adding to the root crontab, but neither work from @reboot.

As to the second, I'm not familiar with .bashrc, but doesn't that just affect the behavior of bash when run? I'm guessing the first needs to work before the second is useful.
I have never used screen before and am just playing around with it now. It seems you want sudo crontab -e (or root's account) and enter there @reboot su math-user -c "cd /your/path && screen your_program &". The ampersand is very important!

Then when you log in or call up a terminal type screen -ls followed by screen -d xxxx and screen -r xxxx where xxxx is the number given by screen -ls

Try it with top: type screen top. Open another terminal and run screen -ls, screen -d xxxx and screen -r xxxx.

Getting this to happen automatically when you open a terminal in say SSH is tricky. However you can write a bash script to pluck out the magic number from screen -ls and have it detach and reattach to your current terminal.

Last fiddled with by paulunderwood on 2022-08-03 at 22:44
paulunderwood is offline   Reply With Quote
Old 2022-08-05, 18:10   #11
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

2·5·7·73 Posts
Default

I'm familiar somewhat with screen and just needed to review some things that are similar but not quite the same as with tmux, which I use much more frequently.

Anyway, no joy with any of this, but it's moved to a lower priority for the moment. I'll come back to it and play some more eventually. Thanks for reminding me of the trailing ampersand. Maybe that's part of previous failures.

Thank you to you, and all who have provided some thoughts toward an eventual resolution.
EdH is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prime95 doesn't start automatically even with "Start at Logon" enabled ixfd64 Software 4 2022-05-14 05:05
Where is "swpon" and such in Debian buster? EdH Linux 4 2022-03-27 16:25
BASH script segment won't work in larger script EdH Programming 41 2021-10-15 22:07
Debian 10 "Buster" released paulunderwood Linux 5 2019-09-07 12:59
Howto start mprime automically for (Debian) Linux joblack Software 26 2018-11-05 11:18

All times are UTC. The time now is 10:17.


Tue Dec 6 10:17:25 UTC 2022 up 110 days, 7:45, 0 users, load averages: 0.89, 0.82, 0.85

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔