Daedalus Development Ltd
Registered in England and Wales No: 8123893
Registered Office:
2nd Floor, Hathaway House
Popes Drive
London N3 1QF
Running mprime (a.k.a. primenet, gimps) as a daemon on Linux
mprime is a program that is used to calculate Mersenne primes. For more information on Mersenne primes, see GIMPS - the Great Internet Mersenne Prime Search.
To run mprime as a daemon on Linux (i.e. mprime will start in the background whenever the server boots) first download and install the software as per the instructions. The following instructions assume that mprime is installed in the directory /opt/mprime. You can change this path to whatever you like. The paths are correct for a Mandrake 8.2 / RedHat distro, but may need altering for other distros.First, create the file /usr/bin/mprime (view file) and put the following lines in it:
#! /bin/sh
/opt/mprime/mprime -d -w/opt/mprime >> /var/log/mprime &
You will need to make this file executable (for example chmod a+x
/usr/bin/mprime
). You can now start mprime by running the command
mprime
(assuming that /usr/bin is in your path).
Then create the file /etc/init.d/mprimed (view file) (this may need to be created in /etc/rc.d/init.d if /etc/init.d does not exist) and put the following lines in it:
#!/bin/sh
#
# chkconfig: 345 95 05
# description: Starts and stops the mprime program \
# used to calculate Mersenne primes.
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
RETVAL=0
start() {
status mprime > /dev/null
RETVAL=$?
if [ $RETVAL -gt 0 ]; then
echo -n "Starting mprime: "
daemon mprime
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mprime || \
RETVAL=1
return $RETVAL
fi
}
stop() {
status mprime > /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo -n "Shutting down mprime: "
killproc mprime
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mprime
return $RETVAL
fi
}
restart() {
stop
start
}
mdkstatus() {
status mprime
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
mdkstatus
;;
condrestart)
[ -f /var/lock/subsys/mprime ] && restart || :
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $?
You will also need to make this file executable (for example chmod a+x
/etc/init.d/mprimed
).
Once this is done, you should be able to start and stop the daemon by using
/etc/init.d/mprimed start
and /etc/init.d/mprimed stop
.
To start the daemon automatically on boot, run chkconfig mprimed on
and to check that it is running, run ps ax | grep mprime
or /etc/init.d/mprimed status
.