View Single Post
Old 2022-08-03, 22:31   #10
paulunderwood's Avatar
Sep 2002
Database er0rr

54×7 Posts

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