mersenneforum.org Howto start mprime automically for (Debian) Linux
 Register FAQ Search Today's Posts Mark Forums Read

2010-06-22, 17:50   #12
lfm

Jul 2006
Calgary

1101010012 Posts

Quote:
 Originally Posted by joblack I know but why did he write it. By the way: su means 'substitute user' and not superuser (you can switch to another (normal) user as well).
he was suggesting you use the su command to run mprime as a normal user from the /etc/rc.local init file. its a good idea to not run stuff like mprime as root when it isn't needed.

2010-06-29, 10:55   #13
joblack

Oct 2008
n00bville

10110110102 Posts

Quote:
 Originally Posted by lfm he was suggesting you use the su command to run mprime as a normal user from the /etc/rc.local init file. its a good idea to not run stuff like mprime as root when it isn't needed.
I don't run it as root as you can see under 'su $user -c ...'. The /etc/rc.local isn't LSB standard conform and can be found on SuSE machines. 2010-06-30, 00:03 #14 lfm Jul 2006 Calgary 1A916 Posts Quote:  Originally Posted by joblack I don't run it as root as you can see under 'su$user -c ...'. The /etc/rc.local isn't LSB standard conform and can be found on SuSE machines.
yes, he was talking about ubuntu. On suse there is equivalent files in /etc/rc.d/rc.local or /etc/init.d/rc.local or something similar. Sometimes even more than one.

Frankly I don't recomend any of them, I prefer the crontab @reboot command.

 2010-07-20, 12:52 #15 markr     "Mark" Feb 2003 Sydney 10758 Posts I tried the OP's method in Ubuntu, but all I got was this error message : "su: must be run from a terminal". I think they've disabled su in scripts as a security measure. A bit of googling only found people trying to run something as root in a script. I've set up the crontab @reboot method instead.
2013-09-15, 21:49   #16
nicko7i

Sep 2013

12 Posts
More on the @reboot approach

Quote:
 Originally Posted by lfm An alternative that works well for me is: echo "@reboot cd ~/gimps ; ./mprime & " | crontab - Assuming you aren't already using crontab.
I wanted to elaborate on this suggestion. It took me a few tries to get it right, so maybe I can save someone some effort.

I installed the software in the directory '/opt/mprime'. This directory and all its files are owned by user 'nick'.

To have 'cron' automatically start the program, I created a file mprime in the /etc/cron.d directory. This file must be an ordinary text file; it must be owned by root; and it must not be write-able except by root. The file contains a single line:

@reboot nick /opt/mprime/mprime -w/opt/mprime

You can create the file with your favorite text editor, or by executing the following command (the "%" represents the prompt and is not typed as part of the command):

% sudo bash -c "echo '@reboot nick /opt/mprime/mprime -w/opt/mprime' > /etc/cron.d/mprime"

In my example, the program runs as user 'nick'. Replace 'nick' with the name of a non-privileged user and the path '/opt/mprime' with the complete path to the directory where 'mprime' lives.

If 'mprime' doesn't start after rebooting, you can check for an error message with this command:

% sudo fgrep cron /var/log/messages

I'm using SuSE 12.x. I believe this will also work on Debian/Ubuntu, but I have not tested that myself.

 2018-10-29, 21:46 #17 ET_ Banned     "Luigi" Aug 2002 Team Italia 113538 Posts Five years have passed since the last message on topic. Now, having Ubuntu, and wanting to run mprime in background (./mprime &) and unmanned at each restart of the computer, especially after a power blackout (quite frequent in this season in Italy), what script would you suggest? I have seen flavours of init.d, crontab and rc.local, with pros and cons, and would appreciate your actual hint. Thank you
 2018-10-30, 15:18 #18 Mark Rose     "/X\(‘-‘)/X\" Jan 2013 13·227 Posts I still run it like this, in my personal crontab: @reboot screen -S mprime -d -m /path/to/mprime/mprime -d Then I can reattach to see the output whenever.
2018-11-02, 17:00   #19
ET_
Banned

"Luigi"
Aug 2002
Team Italia

29×167 Posts

Quote:
 Originally Posted by Mark Rose I still run it like this, in my personal crontab: @reboot screen -S mprime -d -m /path/to/mprime/mprime -d Then I can reattach to see the output whenever.
For some strange reason this same command does not run on my PC.
And yes, I used the correct directory

2018-11-02, 17:24   #20
Mark Rose

"/X\(‘-‘)/X\"
Jan 2013

13×227 Posts

Quote:
 Originally Posted by ET_ For some strange reason this same command does not run on my PC. And yes, I used the correct directory
Might need to install screen. Or you could modify it to use tmux, if that's installed or you're more familiar with that.

2018-11-02, 17:50   #21
chalsall
If I May

"Chris Halsall"
Sep 2002

25×331 Posts

Quote:
 Originally Posted by Mark Rose Might need to install screen. Or you could modify it to use tmux, if that's installed or you're more familiar with that.
Or, to avoid any dependencies, I use this:
Code:
@reboot ~/prime/mprime -d </dev/null >>~/prime/mprime.log 2>/dev/null &
Then, if I want, I can log into the machine and "tail -f ~/prime/mprime.log".

2018-11-02, 18:02   #22
ET_
Banned

"Luigi"
Aug 2002
Team Italia

29·167 Posts

Quote:
 Originally Posted by chalsall Or, to avoid any dependencies, I use this: Code: @reboot ~/prime/mprime -d >~/prime/mprime.log 2>/dev/null & Then, if I want, I can log into the machine and "tail -f ~/prime/mprime.log".
It looks like on Ubuntu 16, if you create a user's crontab, you need not insert the username before the command, or the command won't be executed...

Thanks Mark and Chris.

 Similar Threads Thread Thread Starter Forum Replies Last Post pessoft Software 0 2016-06-13 20:58 alexvong1995 Linux 3 2015-05-13 12:49 LaurV Linux 10 2015-04-24 15:39 Batalov Linux 25 2009-09-18 06:38 Matt Linux 1 2007-02-22 22:36

All times are UTC. The time now is 16:40.

Wed Aug 17 16:40:22 UTC 2022 up 41 days, 11:27, 1 user, load averages: 1.28, 1.44, 1.37