Here’s an example of an init script to start and stop Logsurfer on Solaris. Adapt this script to meet your own needs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#!/sbin/sh # # Script to startup / shutdown logsurfer on Solaris # # ToDo : run under another userid # LOGSURFER_HOME=/var/logsurfer LOGSURFER=$LOGSURFER_HOME/bin/logsurfer LOGSURFER_CONFFILE=$LOGSURFER_HOME/etc/logsurfer.conf LOGSURFER_PIDFILE=$LOGSURFER_HOME/dump/logsurfer.pid LOGSURFER_LOGFILE=$LOGSURFER_HOME/log/logsurfer.log LOGSURFER_DUMPFILE=$LOGSURFER_HOME/dump/logsurfer.dump # # Log file for logsurfer stdout, stderr LOGSURFER_LOG=$LOGSURFER_HOME/log/logsurfer.log # # Syslog file to monitor # SYSLOG_FILE=/var/log/syslog case "$1" in 'start') # Start from the current last line of the log file CURRENT_LOG_POS=`wc -l <$SYSLOG_FILE` echo "Logsurfer starting to monitor $SYSLOG_FILE from line $CURRENT_LOG_POS" nohup $LOGSURFER -c $LOGSURFER_CONFFILE \ -d $LOGSURFER_DUMPFILE -f \ -l $CURRENT_LOG_POS -p $LOGSURFER_PIDFILE \ $SYSLOG_FILE >$LOGSURFER_LOG 2>&1 & ;; 'stop') kill -TERM `cat $LOGSURFER_PIDFILE` ;; 'dump') # Dump internal start kill -USR1 `cat $LOGSURFER_PIDFILE` ;; 'reopen') # reopen the input logfile kill -HUP `cat $LOGSURFER_PIDFILE` ;; 'restart') # Restart for config file change # Start from the current last line of the log file CURRENT_LOG_POS=`wc -l <$SYSLOG_FILE` kill -TERM `cat $LOGSURFER_PIDFILE` sleep 3 nohup $LOGSURFER -c $LOGSURFER_CONFFILE \ -d $LOGSURFER_DUMPFILE -f \ -l $CURRENT_LOG_POS -p $LOGSURFER_PIDFILE \ $SYSLOG_FILE >$LOGSURFER_LOG 2>&1 & ;; *) echo "Usage: $0 { start | stop | dump | reopen }" exit 1 ;; esac exit 0 |