1834903 Members
2971 Online
110071 Solutions
New Discussion

start up file

 
SOLVED
Go to solution
Chi Yi Lee
Advisor

start up file

Hi, I made a shell to backup log file everyday, but I didn't want to use cron so I used startup and made it loop forever.

My prob. is that, when the system is reboot and listing all the start up file name and "OK" part, it just stuck at my shell. Is there a way to fix this?

#!/sbin/sh
#syslogbk.sh June 16 2004

###############################################
#
# BACKUP SYSLOG
#
###############################################
export LANG=C
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/contrib/bin:$PATH
log_main=/var/adm/syslog/syslog.log
log_tmp=/var/adm/syslog/syslog.tmp
current_date=`date +%Y/%m/%d'`;
INTERVAL=180

###############################################
#
# FUNCTION:backup_process
#
###############################################
function backup_process
{

while :
do
sleep $INTERVAL
if [$current_date != date +%Y/%m/%d]
then
cat $log_tmp >> /home/kankyo/LOG/syslog.`date '+%Y.%m.%d'`
cat $log_main >> /home/kankyo/LOG/syslog.`date '+%Y.%m.%d'`
rm $log_main
mask=`umask`
umask 022
> /var/adm/syslog/syslog.log
umask $mask
current_date=`date '+%Y/%m/%d'`;
rm $log_tmp
else :
fi
done;
}

###############################################
#
# FUNCTION:temp_process
#
###############################################
function temp_process
{
cat $log_main >> $log_tmp
}

###############################################################################
#
# MAIN:
#
###############################################################################
case $1 in
start_msg)
echo "Starting syslogbk.sh NOW"
;;

stop_msg)
echo "Stoping syslogbk.sh NOW"
;;

start)
logger "syslogbk.sh is Starting"
exit 0;
;;

stop)
temp_process;
;;

backup)
backup_process;
;;

*)
print "usage ${0} [ start_msg | stop_msg | start | stop | backup ]"
exit 0;
::
esac
2 REPLIES 2
Bill Hassell
Honored Contributor
Solution

Re: start up file

This is not a good idea to use a startup script. cron keeps a log for each job and is the best way in Unix to schedule regular events. A startup script MUST put itself into the background because each startup task must be completed before the next task is started. Startup tasks are really designed for starting daemons. Is there a reason not to use cron?


Bill Hassell, sysadmin
Chi Yi Lee
Advisor

Re: start up file

Hi Bill

well there isn't any particular reason that I don't want to use cron. Just that I made the shell already and want to give it a try.

thanks~