Hello,
I'm trying to write a script that checks for previous instances of the same script which may still be running (this script is scheduled to run every 30 minutes). I want to somehow use the pid from each instance to make sure the previous one isn't running before continuing with my... (5 Replies)
Hello all,
I currently connect to several servers multiple times a day. Most of the time I connect via SSH through the terminal emulator poderosa (my personal favorite), but sometimes I connect via telnet through xstart because I need it to export a GUI.
What I want to do is add something to... (3 Replies)
I currently run a script over a vpnc tunnel to back-up my data to a remote server. However for a number of reasons the tunnel often collapses. If I manually restore the tunnel then the whole thing can continue, but I want to add into my script a section whereby while the transfer is taking place,... (8 Replies)
Hi all,
I encountered a problem where my script stops running the remaining checks after becoming an admin that is written within the script.
For example:
=========================================
#!/bin/sh
check 1 # Runs successfully
check 2 # Runs successfully
/com/bin/admin #... (1 Reply)
I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Hi.
I'm triyng to make a Bash Script that checks (recursively) the MD5 from all the files in a certain directory and compare them against some other check that should be already done and saved in a file.
I've reached to the point where i have the MD5 from the file and the MD5 that the script... (1 Reply)
I an using the below functions in my script.
---------
checkRT()
{
subHeader "Runtime Check"
for nn in `cat $HOST_FILE|egrep -i 'msdp|ca|backup|db'|grep -v '#'|sed '/^$/d'|awk '{ print $1":"$2":"$3}'`
do
fhba=`expr $nn|cut -d: -f2`
fhba2=`expr $nn|cut -d: -f3`
subSubHeader $fhba2
ssh... (1 Reply)
Hi ,
I need a script which performs below activity
I have one file named "testfile" in 9 different directories with same name.
I want to perform below action with each testfile of each directory.
if ; then
mv listfiles listfiles_`date +%b%y`
else
echo No Such files
fi
... (4 Replies)
Hi ,
I need a script for processing below scenario.
I have to check daily by doing ftp IP to check it is logging or not.
So i want this activity to be automated such that if login succesful i will get "FTP LOGIN SUCCESS" in a log file and if fails i want the error message in the same log... (1 Reply)
Hello everyone,
I was wondering if any of you could help me with this. I am an absolute beginner and don't know how to program, but I can follow a tutorial and tweak code sometimes. My understanding of programing is limitted to what for and while loops do, and how if then else logic works. That... (2 Replies)
Discussion started by: tomeurp
2 Replies
LEARN ABOUT REDHAT
funlockfile
LOCKFILE(3) Linux Programmer's Manual LOCKFILE(3)NAME
flockfile, ftrylockfile, funlockfile - lock FILE for stdio
SYNOPSIS
#include <stdio.h>
void flockfile(FILE *filehandle);
int ftrylockfile(FILE *filehandle);
void funlockfile(FILE *filehandle);
DESCRIPTION
The stdio functions are thread-safe. This is achieved by assigning to each FILE object a lockcount and (if the lockcount is nonzero) an
owning thread. For each library call, these functions wait until the FILE object is no longer locked by a different thread, then lock it,
do the requested I/O, and unlock the object again.
(Note: this locking has nothing to do with the file locking done by functions like flock(2) and lockf(3).)
All this is invisible to the C-programmer, but there may be two reasons to wish for more detailed control. On the one hand, maybe a series
of I/O actions by one thread belongs together, and should not be interrupted by the I/O of some other thread. On the other hand, maybe the
locking overhead should be avoided for greater efficiency.
To this end, a thread can explicitly lock the FILE object, then do its series of I/O actions, then unlock. This prevents other threads from
coming in between. If the reason for doing this was to achieve greater efficiency, one does the I/O with the non-locking versions of the
stdio functions: with getc_unlocked() and putc_unlocked() instead of getc() and putc().
The flockfile() function waits for *filehandle to be no longer locked by a different thread, then makes the current thread owner of *file-
handle, and increments the lockcount.
The funlockfile() function decrements the lock count.
The ftrylockfile() function is a non-blocking version of flockfile(). It does nothing in case some other thread owns *filehandle, and it
obtains ownership and increments the lockcount otherwise.
RETURN VALUE
The ftrylockfile() function returns zero for success (the lock was obtained), and nonzero for failure.
ERRORS
None.
AVAILABILITY
These functions are available when _POSIX_THREAD_SAFE_FUNCTIONS is defined. They are in libc since libc 5.1.1 and in glibc since glibc 2.0.
CONFORMING TO
POSIX.1
SEE ALSO unlocked_stdio(3)
2001-10-18 LOCKFILE(3)