Osx' S /Etc/Init.D Equivalent

/etc/init.d' or 'service' equivalent on Mac OS X

man launchd

DESCRIPTION
launchd manages processes, both for the system as a whole and for individual users. The pri-
mary and preferred interface to launchd is via the launchctl(1) tool which (among other
options) allows the user or administrator to load and unload jobs. Where possible, it is
preferable for jobs to launch on demand based on criteria specified in their respective con-
figuration files.

During boot launchd is invoked by the kernel to run as the first process on the system and to
further bootstrap the rest of the system.

You cannot invoke launchd directly.

Unix script on startup in /etc/init.d not working

When bash scripts are run, they are not automatically ran from the same directory that contains them.

You will either need to update your scripts to change directory to that which holds the scripts before starting the jar:

#!/bin/bash
cd /var/lib/myapp/
java -jar myapp-1.0.0RC.jar &

Or, refer to the jar file with a full path:

#!/bin/bash
java -jar /var/lib/myapp/myapp-1.0.0RC.jar &

How to start MySQL server from command line on Mac OS Lion?

Try /usr/local/mysql/bin/mysqld_safe

Example:

shell> sudo /usr/local/mysql/bin/mysqld_safe
(Enter your password, if necessary)
(Press Control-Z)
shell> bg
(Press Control-D or enter "exit" to exit the shell)

You can also add these to your bash startup scripts:

export MYSQL_HOME=/usr/local/mysql
alias start_mysql='sudo $MYSQL_HOME/bin/mysqld_safe &'
alias stop_mysql='sudo $MYSQL_HOME/bin/mysqladmin shutdown'

Standard or best way to keep alive process started by init.d

You might want to use the daemon(3) library function inside the code of your daemon. You should be aware of syslog(3) (at least to log error conditions). You probably should catch gently the SIGTERM signal. Read carefully signal(7)

Server programs are often event loop based (and it is conceptually an infinite loop). You'll either use en existing event loop library (e.g. libev, libevent, glib, ...) or build your own one around a multiplexing syscall like poll(2)

Read Advanced Linux Programming and study the source code of some existing free software daemon.

Perhaps dbus is also relevant for your goals (which I don't really understand: what does "looks for down process" exactly means? You could set some limits with setrlimit(2) often invoked thru the ulimit bash builtin in some .bashrc)

There is also the @reboot entry for crontab(5), but that is not the recommended practice for system daemons (however you could use it in your user crontab file).

find httpd running or not using /etc/init.d/httpd inside script

$? will give you the value of the most recent return code. E.g.

/etc/init.d/httpd status > /dev/null # ignore stdout
if [ $? -eq 0 ]; then
echo "yes"
else
echo "no"
fi

For more details, see http://tldp.org/LDP/abs/html/exit-status.html

How do I translate init.d scripts from Ubuntu/Debian Linux to Solaris?

start-stop-daemon is a Linux thing, and not used that much on Solaris. I guess you can port the command though, if you want to reuse your init scripts.

Otherwise it depends on what version of Solaris you are using. Starting with Solaris 10 and also OpenSolaris they use a new startup script framework "Solaris Service Management Facility", which you configure with the commands svcs, svccfg and svcadm.

See http://www.oracle.com/technetwork/server-storage/solaris/overview/servicemgmthowto-jsp-135655.html for more information.

For older Solaris releases most init scripts are written in pure shell without any helper commands like start-stop-daemon.

Ubuntu tells me my init.d Service of spring boot application not found and can not to run it

I used the command of sudo chmod +x /etc/inti.d/appname and used command of sudo /etc/init.d/appname start. It works.



Related Topics



Leave a reply



Submit