Startup Script "run process with Timer"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Startup Script "run process with Timer"
# 1  
Old 08-21-2008
Startup Script "run process with Timer"

Hi
I have a script that execute every X minute for checking new files in a folder and converting to pdf.
Is there any way to start this script automatically on linux startup?. I use sleep function in script with infinite loop.

while [ 1 -lt 2 ]
do

killall -u `whoami` -q soffice
soffice -invisible -norestore -nofirststartwizard -nologo -headless "-accept=socket,host=localhost,port=8100;urp;" &
sleep 15s
find /temp/papers/ -name *^.doc | while read a;
do

filename=`echo "$a" | sed 's/\(.*\)...../\1/'`
echo Converting $filename.doc
python DocumentConverter.py "$filename^.doc" "$filename.pdf"
errorcode=$?
if [ $errorcode -eq 0 ]; then
mv "$a" "$filename.doc"
echo Successfully Convert $filename.doc
fi
if [ 0 -lt $errorcode ]; then
echo Can not convert $filename.doc error $errorcode
fi
done
killall -u `whoami` soffice
sleep 60s
done

I run the above script from Terminal, it is working fine.
I would like to start this process automatically on my linux startup.
So I put calling my script file in /etc/rc.d/rc.local.
When I reboot, OS hang on startup. I think OS is looping infinite loop of my script.

How can I solve?

Image Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Tips and Tutorials

My "Bread and Butter" Process Keep Alive Perl Script....

For the newbies, I should have posted this years ago.... Here is the standard (tiny) "bread and butter" perl script (on Linux) I use in my crontab files to insure key processes are alive ( just in case ! ) like httpd, named, sshd, etc. The example below if for named...... ... (1 Reply)
Discussion started by: Neo
1 Replies

3. Shell Programming and Scripting

How to put a "timer" when running df - NFS error

Hi gurus, OS = SunOS 5.8 Not sure whether to post this in the scripting one or to advance and experts. Am posting on both since there is two things that am wanting to achieve. Am currerntly having NFS server errors where it is having problems NFS mounting some of the volumes from the... (1 Reply)
Discussion started by: newbie_01
1 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

"Cannot allocate memory" error when run from script

hi in my application there is a line with open(/dev/mydevice,0); it work good when it run manually, but when try to run it within script /////////////////////////////////////////// #!/bin/sh ./device_test 0 0 0 1 1 1 0 0 1 ///////////////////////////////////////// I receive 'Failed... (3 Replies)
Discussion started by: majeed
3 Replies

6. Shell Programming and Scripting

Ksh script function, how to "EXIT 2" without killing the current process?

Hi, Using AIX 5.3 and Ksh. />ls -al /usr/bin/ksh -r-xr-xr-x 5 bin bin 237420 Apr 10 2007 /usr/bin/ksh /> I recently started working for a new employer. I have written UNIX K-Shell scripts for many years and have never had this particular issue before. Its perplexing me. I have... (2 Replies)
Discussion started by: troym72
2 Replies

7. Red Hat

"service" , "process" and " daemon" ?

Friends , Anybody plz tell me what is the basic difference between "service" , "process" and " daemon" ? Waiting for kind reply .. .. (1 Reply)
Discussion started by: shipon_97
1 Replies

8. Shell Programming and Scripting

catalina.sh : need combination from "start" and "run"

heya, can someone help me with following problem. i am not sure how far you know the catalina.sh script from tomcat. when i start my tomcat with "catalina.sh run" then the startup-process-output will be printed out on the console, but the tomcat process is started in current shell/session, so... (1 Reply)
Discussion started by: Filly
1 Replies

9. Shell Programming and Scripting

How to make a script run for a maximum of "x" number of hours only

How to make a script run for a maximum of "x" number of hours only (7 Replies)
Discussion started by: ScriptDummy
7 Replies

10. UNIX for Dummies Questions & Answers

Run away "bootpgw" & "inetd"

Hello All. I'm get the following messages posted to the /var/adm/syslog file ever second and not sure on how to stop the process. May 14 15:50:52 a3360 bootpgw: version 2.3.5 May 14 15:50:52 a3360 inetd: /etc/bootpgw exit 0x1 As said about this gets logged every second only thing that... (4 Replies)
Discussion started by: cfaiman
4 Replies
Login or Register to Ask a Question
RC(8)							    BSD System Manager's Manual 						     RC(8)

NAME
rc, rc.local, rc.shutdown, rc.d/ -- startup and shutdown scripts SYNOPSIS
rc rc.local rc.shutdown rc.d/ DESCRIPTION
rc is the command script which controls the startup of various services, and is invoked by init(8) as part of the process of entering the automatic reboot to multi-user startup, or after the single user mode shell has exited. If init(8) is starting the automatic reboot process, rc is invoked with the argument of 'autoboot'. rc.local is a command script to which local boot-time actions can be added. It is (nearly) the last thing invoked by rc during a normal boot. rc.shutdown is the command script which shuts down various services, and is invoked by shutdown(8) as part of the process of shutting down the system. rc.d/ is the directory which contains various sh(1) scripts, one for each service, which are called by rc at startup, rc.shutdown at shut- down, and as necessary during system operation to stop, start, restart, reload, or otherwise control the service. Operation of rc 1. Source /etc/rc.subr to load various rc.subr(8) shell functions to use. 2. If autobooting, set autoboot=yes and enable a flag (rc_fast=yes), which prevents the rc.d scripts from performing the check for already running processes (thus speeding up the boot process). This rc_fast=yes speedup won't occur when rc is started up after exiting the single-user shell. 3. Invoke rcorder(8) to order the files in /etc/rc.d/ that do not have a ``nostart'' keyword (refer to rcorder(8)'s -s flag), and assigns the result to a variable. 4. Calls each script in turn using run_rc_script() (from rc.subr(8)), which sets $1 to 'start', and sources the script in a subshell. If the script has a '.sh' suffix then it is sourced directly into the current shell. 5. The output from the above steps is sent to a post-processor. If rc_silent is false, then the post-processor displays the output. If rc_silent is true, then the post-processor invokes the command specified in rc_silent_cmd once for each line, without otherwise display- ing the output. Useful values for rc_silent_cmd include ``:'' to display nothing at all, and ``twiddle'' to display a spinning symbol on the console. Regardless of the value of rc_silent, the post-processor saves the output in /var/run/rc.log. Operation of rc.shutdown 1. Source /etc/rc.subr to load various rc.subr(8) shell functions to use. 2. Invoke rcorder(8) to order the files in /etc/rc.d/ that have a ``shutdown'' keyword (refer to rcorder(8)'s -k flag), reverses that order, and assigns the result to a variable. 3. Calls each script in turn using run_rc_script() (from rc.subr(8)), which sets $1 to 'stop', and sources the script in a subshell. If the script has a '.sh' suffix then it is sourced directly into the current shell. Contents of rc.d/ rc.d/ is located in /etc/rc.d. The following file naming conventions are currently used in rc.d/: ALLUPPERCASE Scripts that are 'placeholders' to ensure that certain operations are performed before others. In order of startup, these are: NETWORKING Ensure basic network services are running, including general network configuration (network) and dhclient. SERVERS Ensure basic services (such as NETWORKING, ppp, syslogd, and kdc) exist for services that start early (such as named), because they're required by DAEMON below. DAEMON Before all general purpose daemons such as dhcpd, lpd, and ntpd. LOGIN Before user login services (inetd, telnetd, rshd, sshd, and xdm), as well as before services which might run commands as users (cron, postfix, and sendmail). foo.sh Scripts that are to be sourced into the current shell rather than a subshell have a '.sh' suffix. Extreme care must be taken in using this, as the startup sequence will terminate if the script does. /etc/rc.d/bootconf.sh uses this behav- iour to allow the user to select a different configuration (including /etc/rc.conf) early in the boot. bar Scripts that are sourced in a subshell. The boot does not stop if such a script terminates with a non-zero status, but a script can stop the boot if necessary by invoking the stop_boot() function (from rc.subr(8)). Each script should contain rcorder(8) keywords, especially an appropriate ``PROVIDE'' entry. The scripts are expected to support at least the following arguments: start Start the service. This should check that the service is to be started as specified by rc.conf(5). Also checks if the ser- vice is already running and refuses to start if it is. This latter check is not performed by standard NetBSD scripts if the system is starting directly to multi-user mode, to speed up the boot process. stop If the service is to be started as specified by rc.conf(5), stop the service. This should check that the service is running and complain if it's not. restart Perform a stop then a start. status If the script starts a process (rather than performing a one-off operation), show the status of the process. Otherwise it's not necessary to support this argument. Defaults to displaying the process ID of the program (if running). poll If the script starts a process (rather than performing a one-off operation), wait for the command to exit. Otherwise it's not necessary to support this argument. rcvar Display which rc.conf(5) variables are used to control the startup of the service (if any). Other arguments (such as 'reload', 'dumpdb', etc) can be added if necessary. The argument may have one of the following prefixes to alter its operation: fast Skip the check for an existing running process. Sets rc_fast=yes. force Skips the rc.conf(5) check, ignores a failure result from any of the prerequisite checks, executes the command, and always returns a zero exit status. Sets rc_force=yes. one Skips the rc.conf(5) check, but performs all other prerequisite tests. In order to simplify scripts, the run_rc_command() function from rc.subr(8) may be used. FILES
/etc/rc Startup script called by init(8). /etc/rc.d/ Directory containing control scripts for each service. /etc/rc.local Local startup script. /etc/rc.shutdown Shutdown script called by shutdown(8). /etc/rc.subr Contains rc.subr(8) functions used by various scripts. /etc/rc.conf System startup configuration file. /var/run/rc.log Log file created by rc. SEE ALSO
rc.conf(5), init(8), rc.subr(8), rcorder(8), reboot(8), shutdown(8) Luke Mewburn, "The Design and Implementation of the NetBSD rc.d system", Proceedings of the FREENIX Track: 2001 USENIX Annual Technical Conference, USENIX Association, http://www.usenix.org/publications/library/proceedings/usenix01/freenix01/full_papers/mewburn/mewburn.pdf, June 25-30, 2001. HISTORY
The rc command appeared in 4.0BSD. The /etc/rc.d support was implemented in NetBSD 1.5 by Luke Mewburn <lukem@NetBSD.org>. The post-proces- sor, support for rc_silent, and saving output to a file, was implemented in NetBSD 6.0 by Alan Barrett. BSD
May 14, 2010 BSD