I'm writing a script that will automate the launch of some services on my AIX machine. However, some services are dependent on the successful startup of others. When I start these services manually, I usually just check a log file until I see a message that confirms a successful startup. So, I figure I can integrate this into my script but I'm not sure what the best way to do it is. I was thinking something like this:
but that seems cumbersome for the system (not to mention the fact that I don't think it's working). What would be the best approach here? Thanks for your help.
By the way, I'm using the Korn shell.
As your concern is to check if related service is Up or not running I think you have to deal with "ps -ef"
So if you want to run your script after being sure that apache is Up you can do it like this
If [`ps -ef|egrep -i "http|apache"|wc -l` -gt 1 ]
then
.........
fi
I have, say, a dozen files, and I want to grep for a string of text within them. I don't remember the exact syntax, but let me give it a shot and show you an idea here...
find . -type f -exec grep thisword {} \;
...and there's a way to put more than one grep into the statement, so it will tell... (1 Reply)
Hello, this is probably another really simple tasks for most of you gurus, however I am trying to make a script which takes an input, greps a specific file for that input, prints back to screen the results (which are directory names) and then be able to use the directory names to move files.... (1 Reply)
I have a file that is 20 - 80+ MB in size that is a certain type of log file.
It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example:
The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
This script is supposed to find out if tomcat is running or not.
#!/bin/sh
if netstat -a | grep `grep ${1}: /tomcat/bases | awk -F: '{print $3}'` > /dev/null
then
echo Tomcat for $1 running
else
echo Tomcat for $1 NOT running
fi
the /tomcat/bases is a file that... (2 Replies)
This is driving me crazy, and I'm hoping someone can help me out with this. I'm trying to do a simple while loop to go through a log file. I'm pulling out all of the lines with a specific log line, getting an ID from that line, and once I have a list of IDs I want to loop back through the log and... (2 Replies)
Background
-------------
The Unix flavor can be any amongst Solaris, AIX, HP-UX and Linux. I have below 2 flat files.
File-1
------
Contains 50,000 rows with 2 fields in each row, separated by pipe.
Row structure is like Object_Id|Object_Name, as following:
111|XXX
222|YYY
333|ZZZ
... (6 Replies)
Hi,
I tried to grep ".sh_history" (DOTsh_history) file and did not return anything though I found the word in .sh _history file through vi editor in Linux. Then I tried to grep ".profile" to check if it is the prob with hidden files and I got results.
Then I verified the same with my friend... (4 Replies)
Hi Guys,
I'm trying to write an script that will be launched by a user. The script will look at a log file and check for alerts with the date (supplied by user) and a machine's hostname (also supplied by the user). I'm trying to get the output formatted just like the log file.
The logfile looks... (5 Replies)
Hi all,
Am writing a ksh script where I am looking for processes that has gone defunct and all of which has the same PPID
PID is the variable that I need to match as this is the process ID of the processes that has gone defunct
Am just curious how come the following DOES NOT work?
ps... (6 Replies)
Hi Folks,
While transferring file from FTP software like Filezilla the files gets corrupted.
Is there any way I can check if the recently transferred file is in ASCII and not corrupted. I have tried using file -i filename command which does tell if the file character set is ASCII or binary... (6 Replies)
Discussion started by: Khan28
6 Replies
LEARN ABOUT FREEBSD
service
SERVICE(8) BSD System Manager's Manual SERVICE(8)NAME
service -- control (start/stop/etc.) or list system services
SYNOPSIS
service -e
service -R
service [-v] -l | -r
service [-v] <rc.d script> start|stop|etc.
DESCRIPTION
The service command is an easy interface to the rc.d system. Its primary purpose is to start and stop services provided by the rc.d scripts.
When used for this purpose it will set the same restricted environment that is in use at boot time (see below). It can also be used to list
the scripts using various criteria.
The options are as follows:
-e List services that are enabled. The list of scripts to check is compiled using rcorder(8) the same way that it is done in rc(8), then
that list of scripts is checked for an "rcvar" assignment. If present the script is checked to see if it is enabled.
-R Restart all enabled local services.
-l List all files in /etc/rc.d and the local startup directories. As described in rc.conf(5) this is usually /usr/local/etc/rc.d. All
files will be listed whether they are an actual rc.d script or not.
-r Generate the rcorder(8) as in -e above, but list all of the files, not just what is enabled.
-v Be slightly more verbose
ENVIRONMENT
When used to run rc.d scripts the service command sets HOME to / and PATH to /sbin:/bin:/usr/sbin:/usr/bin which is how they are set in
/etc/rc at boot time.
EXIT STATUS
The service utility exits 0 on success, and >0 if an error occurs.
EXAMPLES
The following are examples of typical usage of the service command:
service named status
service -rv
The following programmable completion entry can be use in bash(1) for the names of the rc.d scripts:
_service () {
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W '$( service -l )' -- $cur ) )
return 0
}
complete -F _service service
SEE ALSO bash(1) (ports/shells/bash), rc.conf(5), rc(8), rcorder(8)HISTORY
The service utility first appeared in FreeBSD 7.3.
AUTHORS
This manual page was written by Douglas Barton <dougb@FreeBSD.org>.
BSD December 11, 2012 BSD