LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 08-22-2009, 12:36 PM   #1
Linux Duke
LQ Newbie
 
Registered: Jan 2009
Location: South Africa
Distribution: Red hat
Posts: 14

Rep: Reputation: 0
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.
 
Old 08-22-2009, 01:53 PM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,775

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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

Last edited by bathory; 08-22-2009 at 01:54 PM.
 
Old 08-23-2009, 03:56 PM   #3
Linux Duke
LQ Newbie
 
Registered: Jan 2009
Location: South Africa
Distribution: Red hat
Posts: 14

Original Poster
Rep: Reputation: 0
Where should my script be locate e.g. /etc/init.d/

Thanks
 
Old 08-23-2009, 04:30 PM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,775

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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

Last edited by bathory; 08-23-2009 at 04:35 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a Linux Startup script?? Cypher12 Linux - Networking 1 12-18-2006 02:16 PM
Startup script for linux Tr@ce Linux - General 2 04-26-2005 03:16 AM
Linux Startup Scripts for Oracle Application & Database research2004 Linux - Newbie 1 04-14-2004 05:22 AM


All times are GMT -5. The time now is 03:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration