![]() |
![]() |
#1 |
"Ed Hall"
Dec 2009
Adirondack Mtns
121648 Posts |
![]()
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. |
![]() |
![]() |
![]() |
#2 |
Sep 2002
Database er0rr
10001100010002 Posts |
![]()
I think you need to use screen as a @reboot cron job.
Details somebody please. |
![]() |
![]() |
![]() |
#3 | |
"Ed Hall"
Dec 2009
Adirondack Mtns
22×7×11×17 Posts |
![]() Quote:
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. |
|
![]() |
![]() |
![]() |
#4 | ||
Dec 2011
After milion nines:)
3·541 Posts |
![]()
I make command (example)
Quote:
in crontab I add line (crontab -e) Quote:
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 |
||
![]() |
![]() |
![]() |
#5 |
Jun 2003
124748 Posts |
![]() |
![]() |
![]() |
![]() |
#6 |
Sep 2009
2×1,213 Posts |
![]()
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. |
![]() |
![]() |
![]() |
#7 |
"Ed Hall"
Dec 2009
Adirondack Mtns
22×7×11×17 Posts |
![]()
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. |
![]() |
![]() |
![]() |
#8 | |
Sep 2002
Database er0rr
10001100010002 Posts |
![]() Quote:
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 |
|
![]() |
![]() |
![]() |
#9 | |
"Ed Hall"
Dec 2009
Adirondack Mtns
22·7·11·17 Posts |
![]() Quote:
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. |
|
![]() |
![]() |
![]() |
#10 | |
Sep 2002
Database er0rr
118816 Posts |
![]() Quote:
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 |
|
![]() |
![]() |
![]() |
#11 |
"Ed Hall"
Dec 2009
Adirondack Mtns
22·7·11·17 Posts |
![]()
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. |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
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 |