View Single Post
Old 2011-03-03, 06:02   #6
mdettweiler
A Sunny Moo
 
mdettweiler's Avatar
 
Aug 2007
USA (GMT-5)

3×2,083 Posts
Default

Quote:
Originally Posted by SSteve View Post
Thanks for the reply. My question is where do I put the mprime (or screen mprime) command to have it automatically run in a window when I log in. If I put it in ~/.bashrc it only runs when I manually open Terminal.
You may want to try a cron job, with a line like this in your crontab:

@reboot cd mprime-directory; ./mprime -d &> stdout.log

(IIRC you can also use @logon in place of @reboot, but @reboot is probably better in this case since it will run even when you're not logged on, and you won't accidentally get two colliding mprimes running if you log in a second time via SSH or the like.)

Once mprime has been started from the cron job, it will pipe all its console output into the text file stdout.log inside your mprime directory. To "attach" (not quite the correct term in this case, but it works approximately similarly) to mprime's console output, open a terminal to the mprime directory and run "tail -f stdout.log". It will display the last handful of console output lines and update the screen with new lines in real time. Ctrl-C will return you to the terminal (but still leave mprime running, since you only Ctrl-C'd the tail command). To stop mprime properly, run "pkill mprime" from a terminal.

There are of course numerous other ways of doing this (running mprime inside screen, for instance--I don't remember the command to start a particular program directly into a detached screen, but I know there is one--you can swap that into the above cron entry in place of the "./mprime -d &> stdout.log" part), but this is one of the more simple methods. You can also use a an /etc/init.d/ script to start mprime (as detailed in tichy's links) but personally I find crontab the easiest since it lets you run the desired command as a non-root user without fancy footwork.
mdettweiler is offline   Reply With Quote