03-02-2019
Hey bakunin,
Many thanks for your reply!
the following is my plan and let me know if anything doesnt make sense :
1. Ideally the script should print out the log file in the following format:
2019-02-26 09:15:00 +1100,Success,ntpd,restart 2019-02-26 09:16:00 +1100,Error,ntpd,other-activity
But if I am really stuck,as long as the "$(success status),$(service name),$(activity)" are in the output then it will still be fine, someone will extend the script later on..
2. and the fields that I want in the log should include, the last three fields are the minimum and the date is optional depending on the complexity:
$(date and time in fixed format), $(success status), $(service name), $(activity)
3. single log vs multiple logs: I shouldve clarified earlier that the only service I need to work on is ntpd. So a single log would be fine for me.
4. I am not sure if it will be more complicated to write a separate error log since I only need to focus on one service which is ntpd.
Let me know if it makes sense to move on to the next step. thanks again for your help!
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello!
I would like to generate an xml file from the output of various commands generated from within a shell script (some will be in CDATA).
At the moment the only solution I have come up with is echoing xml tags around the commands eg.
echo "<bitism>" >> outputfile
/usr/sbin/prtconf... (1 Reply)
Discussion started by: speedieB
1 Replies
2. Shell Programming and Scripting
My problem looks like it should have a simple solution but it seems that after many days of research I cannot find a good solution. What I have is an input file that contains lines of information. What I need is to extract specific information from that file. What I know is that somewhere in the... (2 Replies)
Discussion started by: eback
2 Replies
3. Shell Programming and Scripting
Hi All,
I need to generate 4 digit random no using only shell script.
Please help in this ASAP.
Thanks in advance...
Regards,
sridhar. (1 Reply)
Discussion started by: sridhusha
1 Replies
4. Shell Programming and Scripting
Can someone help me write this shell script?
I am completely new to shell and as a fun task my uncle has challenged me a problem (out of all other people). Basically, all he wants me to do is to create backup file in a folder that is named “disables.”
This is what he said: create a shell script... (0 Replies)
Discussion started by: hotcutiepie05
0 Replies
5. Infrastructure Monitoring
Good morning to you all
I´m kinda of a noob to scripting, and my knowledge is still very basic: anyway, I´ve developed a small .sh script with the following purpose:
- it will check a result file, checking if it has any values, or if it´s empty
- if it´s empty it will send an email
What... (0 Replies)
Discussion started by: zarahel
0 Replies
6. Shell Programming and Scripting
Hello all,
I want to write a shell script to list the contents of a directory and number them and write them to a file.
For example, if I have a directory temp and the contents of the directory are alpha, beta and gamma. I want to write these filenames to a file "test" in a numbered manner.
... (7 Replies)
Discussion started by: grajp002
7 Replies
7. Shell Programming and Scripting
Unix Gurus,
I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored.
I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Discussion started by: shankar1dada
1 Replies
8. Shell Programming and Scripting
Hello,
Ubuntu server 11.10
can anybody help what is problem with my shell script?
#!/bin/bash
#script to find out currently logged on user is root or not.
if ]
then
echo "You are super"
else
echo "You are awesome!"
fi
When I run script, I get following output
./uid: line 3:
I... (4 Replies)
Discussion started by: kaustubh
4 Replies
9. Shell Programming and Scripting
Requirement is
I have two files their format is
File1 - input_file
-----
tmp_value|3|number||
tmp_value1|3|alpha||
tmp_value2|6|alpha|AA AA|
tmp_value3|15|number|000000005|
tmp_value4|15|number|000000000000000|
tmp_value5|11|alpha|bbbbbbbbbbb|
tmp_value6|11|alpha|bb bb|
input_file ... (4 Replies)
Discussion started by: greenworld123
4 Replies
10. Shell Programming and Scripting
Hi,
I've written a shell script with proper intentation and commenting structure. However, I would like to generate documentation for the shell which I have written. Is there any tool as such to generate it like we have javagen/docgen ?
Please help.
Thanks,
Arjun (0 Replies)
Discussion started by: arjun_arippa
0 Replies
runsv(8) System Manager's Manual runsv(8)
NAME
runsv - starts and monitors a service and optionally an appendant log service
SYNOPSIS
runsv service
DESCRIPTION
service must be a directory.
runsv switches to the directory service and starts ./run. If ./run exits and ./finish exists, runsv starts ./finish. If ./finish doesn't
exist or ./finish exits, runsv restarts ./run.
If ./run or ./finish exit immediately, runsv waits a second before starting ./finish or restarting ./run.
Two arguments are given to ./finish. The first one is ./run's exit code, or -1 if ./run didn't exit normally. The second one is the least
significant byte of the exit status as determined by waitpid(2); for instance it is 0 if ./run exited normally, and the signal number if
./run was terminated by a signal. If runsv cannot start ./run for some reason, the exit code is 111 and the status is 0.
If the file service/down exists, runsv does not start ./run immediately. The control interface (see below) can be used to start the ser-
vice and to give other commands to runsv.
If the directory service/log exists, runsv creates a pipe, redirects service/run's and service/finish's standard output to the pipe,
switches to the directory service/log and starts ./run (and ./finish) exactly as described above for the service directory. The standard
input of the log service is redirected to read from the pipe.
runsv maintains status information in a binary format (compatible to the daemontools' supervise program) in service/supervise/status and
service/log/supervise/status, and in a human-readable format in service/supervise/stat, service/log/supervise/stat, service/supervise/pid,
service/log/supervise/pid.
CONTROL
The named pipes service/supervise/control, and (optionally) service/log/supervise/control are provided to give commands to runsv. You can
use sv(8) to control the service or just write one of the following characters to the named pipe:
u Up. If the service is not running, start it. If the service stops, restart it.
d Down. If the service is running, send it a TERM signal, and then a CONT signal. If ./run exits, start ./finish if it exists.
After it stops, do not restart service.
o Once. If the service is not running, start it. Do not restart it if it stops.
p Pause. If the service is running, send it a STOP signal.
c Continue. If the service is running, send it a CONT signal.
h Hangup. If the service is running, send it a HUP signal.
a Alarm. If the service is running, send it a ALRM signal.
i Interrupt. If the service is running, send it a INT signal.
q Quit. If the service is running, send it a QUIT signal.
1 User-defined 1. If the service is running, send it a USR1 signal.
2 User-defined 2. If the service is running, send it a USR2 signal.
t Terminate. If the service is running, send it a TERM signal.
k Kill. If the service is running, send it a KILL signal.
x Exit. If the service is running, send it a TERM signal, and then a CONT signal. Do not restart the service. If the service is
down, and no log service exists, runsv exits. If the service is down and a log service exists, runsv closes the standard input of
the log service, and waits for it to terminate. If the log service is down, runsv exits. This command is ignored if it is given to
service/log/supervise/control.
Example: to send a TERM signal to the socklog-unix service, either do
# sv term /etc/service/socklog-unix
or
# printf t >/etc/service/socklog-unix/supervise/control
printf(1) usually blocks if no runsv process is running in the service directory.
CUSTOMIZE CONTROL
For each control character c sent to the control pipe, runsv first checks if service/control/c exists and is executable. If so, it starts
service/control/c and waits for it to terminate, before interpreting the command. If the program exits with return code 0, runsv refrains
from sending the service the corresponding signal. The command o is always considered as command u. On command d first service/control/t
is checked, and then service/control/d. On command x first service/control/t is checked, and then service/control/x. The control of the
optional log service cannot be customized.
SIGNALS
If runsv receives a TERM signal, it acts as if the character x was written to the control pipe.
EXIT CODES
runsv exits 111 on an error on startup or if another runsv is running in service.
runsv exits 0 if it was told to exit.
SEE ALSO
sv(8), chpst(8), svlogd(8), runit(8), runit-init(8), runsvdir(8), runsvchdir(8), utmpset(8)
http://smarden.org/runit/
AUTHOR
Gerrit Pape <pape@smarden.org>
runsv(8)