- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Doesn't execute the command in my init script?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2005 04:09 AM
тАО06-17-2005 04:09 AM
I wrote the following script and saved it in /etc/init.d/ directory as jabber_init:
#!/bin/bash
#
# Setting Configuration
#
# chkconfig: 3 98 1
# description: Setting Jabber Configuration
#
start() {
/bin/touch /root/karthik.txt
/bin/chmod 777 /root/karthik.txt
}
stop() {
exit 0;
}
and added it to boot-up sequence using the following steps:
1. chkconfig jabber_init --add
which created file called S98jabber_init in /etc/rc3.d folder
2. chkconfig --list jabber_init
jabber_init 0:off 1:off 2:off 3:on 4:off 5:off 6:off
3. The file permissions of /etc/init.d/jabber_init is below:
ll /etc/init.d/jabber_init
-rwxr-xr-x 1 root root 229 Jun 17 20:36 /etc/init.d/jabber_init
When I rebooted the machine, syslog told that jabber_init succeeded:
Jun 17 20:39:15 symlin5 rc: Starting jabber_init: succeeded
But the file /root/karthik.txt didn't got created and the chmod command didn't worked.
Any clues/pointers would be helpful. I'm a newbie to SysAdmin. I checked the internet, googled a bit, but couldn't get any clues.
The system I am using is:
Red Hat Enterprise Linux AS release 3 (Taroon Update 3)
Thanks & Regards,
Karthik D
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2005 04:51 AM
тАО06-17-2005 04:51 AM
Re: Doesn't execute the command in my init script?
ls -l /etc/rc3.d/S98jabber_init
Also, you could redirect output at end of lines :
/bin/touch /root/karthik.txt >>/tmp/logfile 2>&1
/bin/chmod 777 /root/karthik.txt >>/tmp/logfile 2>&1
It will show you in /tmp/logfile what's happening (if something happens). Maybe at execution time, script doesn't have permission to write to /root (it may be launched by bin user, not by root).
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2005 05:02 AM
тАО06-17-2005 05:02 AM
Re: Doesn't execute the command in my init script?
If you don't set a PATH variable, the command you think should be executing may not be executing, leading to no file creation.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2005 05:10 AM
тАО06-17-2005 05:10 AM
Re: Doesn't execute the command in my init script?
Thanks for your reply.
1. ls -l /etc/rc3.d/S98jabber_init
lrwxrwxrwx 1 root root 21 Jun 17 20:36 /etc/rc3.d/S98jabber_init -> ../init.d/jabber_init
2. I did the changes to the script. But nothing got writtent to /tmp/logfile.
ls -l for tmp
drwxrwxrwt 6 root root 4096 Jun 17 22:25 tmp
3. Below are contents of /tmp
total 8
-rwxrwxrwx 1 root root 0 Jun 17 22:22 logfile
drwx------ 2 root root 4096 Oct 15 2004 orbit-root
drwx------ 2 root root 4096 Oct 15 2004 ssh-hPue3517
I created the logfile in temp using touch /tmp/logfile and did chmod 777 logfile before rebooting the system.
SEP:
What PATH variable needs to be set? I don't understand.
Thanks & Regards,
Karthik D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2005 05:12 AM
тАО06-17-2005 05:12 AM
Re: Doesn't execute the command in my init script?
. /etc/init.d/functions
remember the beginning dot is important
Hope this helps,
Gopi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2005 06:17 AM
тАО06-17-2005 06:17 AM
Solutionthe way you have written your scrit it only has two routines but no one are been called, so ... nothing are executed.
To have the start routine executed you must put a line at the end just like that
start
Please, if you are a novice in linux and script language and you do not have time to study before implement what you need, try to look a script that exist on /etc/init.d and have it as an example.
regards,
xyko
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2005 01:08 AM
тАО06-19-2005 01:08 AM
Re: Doesn't execute the command in my init script?
Thanks for your time and reply. Your suggestion really worked. Thanks once again to this forum members for helping newbies like me.
As an acknowledgement, I had assigned 10 points to xyko.
Thanks & Regards,
Karthik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2005 04:48 AM
тАО06-20-2005 04:48 AM
Re: Doesn't execute the command in my init script?
start()
{ touch /tmp/foo }
stop()
{ rm /tmp/foo }
start
stop
then regardless of the arguments passed to the script you will run both of the functions. Add lines like this after your functions to make the your script choose the correct action:
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo 'Usage: scriptname (start|stop)'
esac
Most init scripts are setup similarly.
--Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-20-2005 05:16 AM
тАО06-20-2005 05:16 AM
Re: Doesn't execute the command in my init script?
I didn't say to Karthik that putting a start command at the end of the script will correct the script at all. It was only a way to show him why nothing was happening when the script was executed. At the end of my post I suggest him to look at a script in /etc/init.d to see how to write a script to initiate some kind of service because I understood that he does not have good knowledge of script language.
Regards to all,
Xyko