mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Software (https://www.mersenneforum.org/forumdisplay.php?f=10)
-   -   How do I display status on startup with Ubuntu (https://www.mersenneforum.org/showthread.php?t=15320)

SSteve 2011-03-01 07:02

How do I display status on startup with Ubuntu
 
Preamble (go ahead and skip this paragraph): I used to run Prime95 back in the legacy v4.0 days. I stopped when I finally retired my last Windows machine after switching to OS X. (The initial reason I was interested in OS X is because is was built on Unix which I was originally introduced to in college in the early 80s.) Recently I saw that Prime95 was updated to run under OS X so I installed it on two Core 2 Duo iMacs (my rank is currently 1190). I had a quad-core AMD machine that I built but ended up not using gathering dust in the corner of my office. I decided to use it for GIMPS so I installed Ubuntu 10.10 and mprime. I went to System -> Preferences -> Startup Applications and set up the machine to automatically run mprime -d on startup. I can see under System Monitor that it's working.

Here's the question: Instead of having mprime start and run without a window when I start Ubuntu, I'd like to have it open a terminal window and display mprime's status to stdout. I'm not sure how to do this and would appreciate some guidance.

KingKurly 2011-03-01 15:36

[QUOTE=SSteve;254055]Here's the question: Instead of having mprime start and run without a window when I start Ubuntu, I'd like to have it open a terminal window and display mprime's status to stdout. I'm not sure how to do this and would appreciate some guidance.[/QUOTE]
Try the -m switch when starting it up. For even more fun, run mprime inside screen so you can detach and reattach the session while it keeps running.

SSteve 2011-03-01 17:25

[QUOTE=KingKurly;254096]Try the -m switch when starting it up. For even more fun, run mprime inside screen so you can detach and reattach the session while it keeps running.[/QUOTE]

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.

KingKurly 2011-03-01 18:17

[QUOTE=SSteve;254104]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.[/QUOTE]
My apologies, I misunderstood the situation. I'm sorry; I don't have a good answer for you. Have you tried running a search on the forums? Or maybe someone else can chime in hopefully.

tichy 2011-03-01 19:18

[QUOTE=SSteve;254104]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.[/QUOTE]
How about this: [URL]http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/[/URL]

[EDIT] [url]https://help.ubuntu.com/community/UbuntuBootupHowto[/url]

mdettweiler 2011-03-03 06:02

[QUOTE=SSteve;254104]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.[/QUOTE]
You may want to try a cron job, with a line like this in your crontab:

@reboot cd [I]mprime-directory[/I]; ./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.

EdH 2011-03-03 16:56

If you're using Gnome Desktop, the following should be much simpler:

Note: for the following, my path to mprime is /home/math01/Mathwork/mprime/ and the script is stored in /home/math01/Mathwork/.

1. write a bash script using your favorite text editor
- - example:
[code]
#!/bin/bash

cd /home/math01/Mathwork/mprime
gnome-terminal -e "./mprime"
[/code]- - (saved in /home/math01/Mathwork/ as mprimear.sh)

2. test bash script by opening a terminal in Mathwork and trying:
[code]
bash mprimear.sh
[/code]3. open System>Preferences>Startup Applications
4. choose Add
[code]
Name: Mprime Autorun
Command: bash /home/math01/Mathwork/mprimear.sh
Comment: starts mprime at logon
[/code]5. choose Save
6. note that checkbox on left is checked
7. choose Close

You should be able to convert my paths to yours and add the mprime switches within the quotes.:smile:

This should now autorun in a terminal window whenever you log on.

SSteve 2011-03-04 05:14

[QUOTE=EdH;254234]If you're using Gnome Desktop, the following should be much simpler:[/QUOTE]

Perfect! That's exactly what I was looking for. The gnome-terminal command was the trick. I had tried using screen, but it didn't bring up anything visible. Thanks a ton.


All times are UTC. The time now is 23:05.

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