Sponsored Content
Full Discussion: Retry Logic But In Cron
Top Forums UNIX for Beginners Questions & Answers Retry Logic But In Cron Post 303046120 by jgt on Friday 24th of April 2020 10:58:49 AM
Old 04-24-2020
In the following, the index file is placed in the requests directory, and the image file in the temp directory. The index files can have different extensions to indicate grouping or priority.
The pid file is used to prevent subsequent invocations of the cron job from running.
You can periodically examine the contents of the temp and request directories for entries that older than some specified time.


Code:
#!/bin/ksh
cd /u/email
BATCH=$1
proc=$$
if [ -r /u/email/$BATCH.pid ]
then
    echo "Previous batch  still running" $(cat $BATCH.pid)
    exit
fi
echo $proc >/u/email/$BATCH.pid
list=$(ls requests|grep $BATCH)
if [ "$list" != "" ]
    then
    for request in $list
    do
    #do processing here          
    #if successful 
        mv requests/$request done
        mv temp/$request* done
    #else
       #echo "This one failed"
       #fi
    done
fi
rm /u/email/$BATCH.pid
echo finished at $(date)

 

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Retry upon FTP failure

I am using the following code in a C Shell script to transfer files to a remote server: ftp -n logxx.xxxx.xxx.xxx.com <<DO_FTP1 quote user $user_name quote pass $password ascii put $js_file_name bin put $FinalZipFile quit DO_FTP1 This code works great except on those rare occasions... (8 Replies)
Discussion started by: phudgens
8 Replies

2. Shell Programming and Scripting

If then else - Retry operation

I need to read a file line by line, then depending on the contents of each line, type in a code that will get written to an array. The problem I have is when I ask the user to confirm the input code, if it is wrong, how do i Return to ask again? Any thing I try increments the file to the next... (6 Replies)
Discussion started by: kcpoole
6 Replies
PKCHECK(1)							      pkcheck								PKCHECK(1)

NAME
pkcheck - Check whether a process is authorized SYNOPSIS
pkcheck [--version] [--help] pkcheck [--list-temp] pkcheck [--revoke-temp] pkcheck --action-id action {--process { pid | pid,pid-start-time | pid,pid-start-time,uid } | --system-bus-name busname} [--allow-user-interaction] [--enable-internal-agent] [--detail key value...] DESCRIPTION
pkcheck is used to check whether a process, specified by either --process (see below) or --system-bus-name, is authorized for action. The --detail option can be used zero or more times to pass details about action. If --allow-user-interaction is passed, pkcheck blocks while waiting for authentication. The invocation pkcheck --list-temp will list all temporary authorizations for the current session and pkcheck --revoke-temp will revoke all temporary authorizations for the current session. This command is a simple wrapper around the polkit D-Bus interface; see the D-Bus interface documentation for details. RETURN VALUE
If the specified process is authorized, pkcheck exits with a return value of 0. If the authorization result contains any details, these are printed on standard output as key/value pairs using environment style reporting, e.g. first the key followed by a an equal sign, then the value followed by a newline. KEY1=VALUE1 KEY2=VALUE2 KEY3=VALUE3 ... Octects that are not in [a-zA-Z0-9_] are escaped using octal codes prefixed with . For example, the UTF-8 string fol, will be printed as f303270l54344275240345245275. If the specificied process is not authorized, pkcheck exits with a return value of 1 and a diagnostic message is printed on standard error. Details are printed on standard output. If the specificied process is not authorized because no suitable authentication agent is available or if the --allow-user-interaction wasn't passed, pkcheck exits with a return value of 2 and a diagnostic message is printed on standard error. Details are printed on standard output. If the specificied process is not authorized because the authentication dialog / request was dismissed by the user, pkcheck exits with a return value of 3 and a diagnostic message is printed on standard error. Details are printed on standard output. If an error occured while checking for authorization, pkcheck exits with a return value of 127 with a diagnostic message printed on standard error. If one or more of the options passed are malformed, pkcheck exits with a return value of 126. If stdin is a tty, then this manual page is also shown. NOTES
Do not use either the bare pid or pid,start-time syntax forms for --process. There are race conditions in both. New code should always use pid,pid-start-time,uid. The value of start-time can be determined by consulting e.g. the proc(5) file system depending on the operating system. If fewer than 3 arguments are passed, pkcheck will attempt to look up them up internally, but note that this may be racy. If your program is a daemon with e.g. a custom Unix domain socket, you should determine the uid parameter via operating system mechanisms such as PEERCRED. AUTHENTICATION AGENT
pkcheck, like any other polkit application, will use the authentication agent registered for the process in question. However, if no authentication agent is available, then pkcheck can register its own textual authentication agent if the option --enable-internal-agent is passed. AUTHOR
Written by David Zeuthen <davidz@redhat.com> with a lot of help from many others. BUGS
Please send bug reports to either the distribution or the polkit-devel mailing list, see the link http://lists.freedesktop.org/mailman/listinfo/polkit-devel on how to subscribe. SEE ALSO
polkit(8), polkitd(8), pkaction(1), pkexec(1), pkttyagent(1) polkit May 2009 PKCHECK(1)
All times are GMT -4. The time now is 02:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy