07-25-2005
Posting to a log file in KSH
Hello,
I am writing this script in ksh (consisting of various functions such as -> read_file, write_file, pront_output and initialise) which basically process input files based on the parameters it contains.
My task now is to write any error conditions trapped by any of the function above to a log file.
What is the easiest way that it can be done..?
logfile_name=$logfile_dir/create_vobs_`date +%d%b%y_%T`_$$.log
....and this is what I want it to do....
function read_structure_file
{
# --------------------------------------------------------------------------------------------------------
# Purpose: A compound array (STRUCTURE_FILE) is read in and based on the parameters, data is stored in
# successive arrays
# No arguments
# --------------------------------------------------------------------------------------------------------
struc_file=/develop/sid/si.dat
if [ ! -f $struc_file ]
then
echo "$logfile_dir/create_vobs_Structure file doesn't exist`date +%d%b%y_%T`_$$.log"
exit 1
else
exec < $struc_file
......blah blah
Write the one highlighted above to the log created everytime the program is run.
Thanks in advance.
Sid
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I tried to remove the -ksh.log from my directory
using rm -f -ksh.log
but i cann't do it ,please help how can i do it and also would like to know when this file will be created.
many thanks in advance...
Regards,
HAA (0 Replies)
Discussion started by: HAA
0 Replies
2. Shell Programming and Scripting
I have log files that contain data generated every 5 minutes.
I want to extract data from the log files to another log file
In each 5 minute series
<log4j:event logger="VistaMonitor" timestamp="1200688175425" time="Fri Jan 18 15:29:35 EST 2008"
Generated twice (I only to get the date... (2 Replies)
Discussion started by: CathyPro
2 Replies
3. HP-UX
Hi:
i have writen a script that needs a finishing
Pourpouse is to find a particular error in a file after we enter file name
and the return msg would describe if >there is a error -> "Contact DBA"
if there is no oracle error ->"No ora error found."
for the same i have written a script... (6 Replies)
Discussion started by: techbravo
6 Replies
4. Shell Programming and Scripting
Hello All
Nice to meet you all here in this forum,
it's my 1rst time here
i'm asking about a little issue that i face
i added a ksh script that echo " please insert your name " and store the output to a login.log file.
the script is working fine with normal telnet
but Xstart is not working... (8 Replies)
Discussion started by: islam.said
8 Replies
5. Shell Programming and Scripting
Hi
I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email.
For example
-------
Script ABC
-------
a.ksh
b.ksh
c.ksh
I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies
6. Shell Programming and Scripting
I have a log file like..
IMPORT from /dataserver/ftp/bits/mdr/mdr_data_discon.dat OF DEL .....
Number of rows read = 1376
Number of rows skipped = 0
Number of rows inserted = 1374
Number of rows updated = 0
Number of rows rejected = 2
Number of rows... (4 Replies)
Discussion started by: ramse8pc
4 Replies
7. Shell Programming and Scripting
hi guys, trying to create a csv from a tricky log file in ksh,
using 'awk '{print $1" "$14" "$15" "$16" "$17" "$18" "$19}' >> $TMP_FILE' on another set of files I have an output file with hundreds of lines in which looks like so:
ABC_DEFGHI_16_JKLMNP11.20101115_095412_374.log:09:54:29.579... (3 Replies)
Discussion started by: rich@ardz
3 Replies
8. Shell Programming and Scripting
Hi,
I want to create a log file for a running ksh , and the log file absolute path I want to give in ksh itself.
To elaborate this - Say I have a ksh - timer.ksh and I want to create a log timer_log.log when I run, to trace this. I am aware of the fact that this can be done using redirection... (4 Replies)
Discussion started by: vinay4889
4 Replies
9. Shell Programming and Scripting
I have a log file as given below
012/01/21 10:29:02 (111111) Processing Job '23_369468343464564'
2012/01/21 10:29:02 (111111)
Making Job '23_369468343464564.0'...
2012/01/21 10:29:04 (111111)
Jobnumber '23_369468343464564' was successful
2012/01/21 10:29:04 ... (12 Replies)
Discussion started by: rpm120
12 Replies
10. Shell Programming and Scripting
Hello Team-
we would like to implement an approach which has to write the log file simultaneously
when .sql file is executing by Unix process. At present,it is writing the log file
once the process is completed. I've tested the current process with the below
approaches and none of them... (1 Reply)
Discussion started by: Hima_B
1 Replies
LEARN ABOUT CENTOS
systemd-journald.socket
SYSTEMD-JOURNALD.SERVICE(8) systemd-journald.service SYSTEMD-JOURNALD.SERVICE(8)
NAME
systemd-journald.service, systemd-journald.socket, systemd-journald - Journal service
SYNOPSIS
systemd-journald.service
systemd-journald.socket
/usr/lib/systemd/systemd-journald
DESCRIPTION
systemd-journald is a system service that collects and stores logging data. It creates and maintains structured, indexed journals based on
logging information that is received from the kernel, from user processes via the libc syslog(3) call, from STDOUT/STDERR of system
services or via its native API. It will implicitly collect numerous meta data fields for each log messages in a secure and unfakeable way.
See systemd.journal-fields(7) for more information about the collected meta data.
Log data collected by the journal is primarily text-based but can also include binary data where necessary. All objects stored in the
journal can be up to 2^64-1 bytes in size.
By default, the journal stores log data in /run/log/journal/. Since /run/ is volatile, log data is lost at reboot. To make the data
persistent, it is sufficient to create /var/log/journal/ where systemd-journald will then store the data.
systemd-journald will forward all received log messages to the AF_UNIXSOCK_DGRAM socket /run/systemd/journal/syslog, if it exists, which
may be used by Unix syslog daemons to process the data further.
See journald.conf(5) for information about the configuration of this service.
SIGNALS
SIGUSR1
Request that journal data from /run/ is flushed to /var/ in order to make it persistent (if this is enabled). This must be used after
/var/ is mounted, as otherwise log data from /run is never flushed to /var regardless of the configuration.
SIGUSR2
Request immediate rotation of the journal files.
KERNEL COMMAND LINE
A few configuration parameters from journald.conf may be overridden on the kernel command line:
systemd.journald.forward_to_syslog=, systemd.journald.forward_to_kmsg=, systemd.journald.forward_to_console=
Enables/disables forwarding of collected log messages to syslog, the kernel log buffer or the system console.
See journald.conf(5) for information about these settings.
ACCESS CONTROL
Journal files are, by default, owned and readable by the "systemd-journal" system group but are not writable. Adding a user to this group
thus enables her/him to read the journal files.
By default, each logged in user will get her/his own set of journal files in /var/log/journal/. These files will not be owned by the user,
however, in order to avoid that the user can write to them directly. Instead, file system ACLs are used to ensure the user gets read access
only.
Additional users and groups may be granted access to journal files via file system access control lists (ACL). Distributions and
administrators may choose to grant read access to all members of the "wheel" and "adm" system groups with a command such as the following:
# setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/
Note that this command will update the ACLs both for existing journal files and for future journal files created in the /var/log/journal/
directory.
FILES
/etc/systemd/journald.conf
Configure systemd-journald behaviour. See journald.conf(5).
/run/log/journal/machine-id/*.journal, /run/log/journal/machine-id/*.journal~, /var/log/journal/machine-id/*.journal,
/var/log/journal/machine-id/*.journal~
systemd-journald writes entries to files in /run/log/journal/machine-id/ or /var/log/journal/machine-id/ with the ".journal" suffix. If
the daemon is stopped uncleanly, or if the files are found to be corrupted, they are renamed using the ".journal~" suffix, and
systemd-journald starts writing to a new file. /run is used when /var/log/journal is not available, or when Storage=volatile is set in
the journald.conf(5) configuration file.
SEE ALSO
systemd(1), journalctl(1), journald.conf(5), systemd.journal-fields(7), sd-journal(3), setfacl(1), pydoc systemd.journal.
systemd 208 SYSTEMD-JOURNALD.SERVICE(8)