LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   linux startup script for my application (https://www.linuxquestions.org/questions/linux-server-73/linux-startup-script-for-my-application-749561/)

Linux Duke 08-22-2009 12:36 PM

linux startup script for my application
 
Hi Experts,

I have a script that is store in a directory /data/software/power.sh and this is suppose to be running as the user pwview who owns the directory and belongs to the group users that owns the directory. I need the user pwview to start the script /data/software/power.sh everytime my server is rebooted or shutdown currently I have to manually change to that directory and execute the script ./power.sh as the user pwview and I need this automated by a script that will start the service as the user.

I will highly appreciate a scritp and where this should be that will execute my script when ever my server is booted or after a shutdown.

bathory 08-22-2009 01:53 PM

You can create a script like this:
Code:

#!/bin/sh
/bin/su pwview -c /data/software/power.sh

You have to make it executable and depending on distro put it in the appropriate directory.
If you're using redhat as in your profile you can just add an entry in /etc/rc.d/rc.local like:
Code:

/path/to/my-script

Linux Duke 08-23-2009 03:56 PM

Where should my script be locate e.g. /etc/init.d/

Thanks

bathory 08-23-2009 04:30 PM

You didn't say your distro.
If it's using rc.local (like RH, fedora, Slackware), the script can be located everywhere. You just add a line in rc.local containing the full path to the script.
The same goes for Suse and the file /etc/init.d/boot.local. For others you have to look how they run startup scripts.

Regards


All times are GMT -5. The time now is 10:08 AM.