Research ID - in Crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Research ID - in Crontab
# 1  
Old 05-15-2013
Lightbulb Research ID - in Crontab

Hi,
I have a unix script which runs a process (informatica workflow). To trigger this workflow an entry is made into the crontab and it is scheduled to run.

Issue:
The crontab entry is commented out. But the process is running in the unix box and it was scheduled immediately. There is someone who is running the script manually and it is aborted immediately. The users in a particular group only will have access to do that. There is no change made to the cron tab entries, so there has to be some user who is triggering this process. Problem is ..if someone is triggering the process we cannot have another user doing it. How do i get the user account which triggers this process from the unix log. Is there any log file i could research to find the user id.
# 2  
Old 06-06-2013
Is it possible to customize your process/application?
Add debugging logs like user id, time, etc for temporarily basis.
# 3  
Old 06-15-2013
you do not need crontab entries to run scripts unless you just want them ... the user in question may be running the script directly on the command line or using at so there is no need to modify crontab ... also, the issue may be that it is running in a user's crontab so you may want to check the user crontab files for the entry ... i think your suspect is very likely running the script manually based on your description ...

if you need to restrict the script to one process only while it is running, modify your shell script to use a marker file or at least check for an existing PID of the process prior to continuing the script ... a search of the forums or google should show you how to do so ...
# 4  
Old 06-15-2013
There are two different aspects here: finding out who had run the script and making sure no two instances of the script run simultaneously.

The first is probably impossible. I don't know of any Informatica log file which would tell you this and you probably have not system auditing turned on and configured appropriately to find it in the systems audit logs. You might consider configuring system auditing in the future if you are interested in such information.

Regarding the second problem: this is relatively easy. Change the script so that when it starts it writes a "PID-file". Classically these PID-files are stored in /var/run, are named like the command/process they belong to and contain the PID of the running job. The first thing this script should do is to check if such a PID-file exists. If it does, it aborts with some error, otherwise it creates the PID-file, does whatever it is supposed to do and deletes the PID-file upon exit. Here is a sketch for this:

Code:
#! /bin/ksh

typeset    chProgName="$(basename $0)"
typeset -i iPID=$$

trap { \
     rm -f /var/run/${chProgName}.pid \
     } 0

if [ ! -r /var/run/${chProgName}.pid ] ; then
     print - $iPID > /var/run/${chProgName}.pid
else
     error_exit "Cannot proceed, another instance runs already"
fi

... normal code begins here ...

exit

I hope this helps.

bakunin
# 5  
Old 06-15-2013
assuming that users are not able to modify shell script on their own ... modified bakunin's code to include logging of user running script ...
Code:
#! /bin/ksh

LOG=/dir/run.log
echo "$0 ran by $LOGNAME on $(date)" >> $LOG

typeset    chProgName="$(basename $0)"
typeset -i iPID=$$

trap { \
     rm -f /var/run/${chProgName}.pid \
     } 0

if [ ! -r /var/run/${chProgName}.pid ] ; then
     print - $iPID > /var/run/${chProgName}.pid
else
     error_exit "Cannot proceed, another instance runs already"
fi

... normal code begins here ...

exit

# 6  
Old 06-16-2013
Add logging to your Unix script:
Code:
#!/bin/sh
echo "`date` ${LOGNAME:-$USER}@`uname -n` running $0 pid $$" >> /tmp/logfile
...

# 7  
Old 06-16-2013
just thinking about it further, if mailx works in your server, just have the script send you email as soon as it runs ... (mixing everybody's code) ...
Code:
#! /bin/ksh
ADMIN=admingroup@some.com
echo "`date` ${LOGNAME:-$USER}@`uname -n` running $0 pid $$" | mailx -s "$0 running on `uname -n`" $ADMIN

Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

NAS Research

Good Afternoon, Are most NASs compatible with Solaris/RedHat? Specifically, I'm looking at Western Digital ones but none of them say they are - I like My Cloud Pro Series PR4100 My Cloud Pro Series PR4100 – Network Attached Storage | Western Digital (WD) (3 Replies)
Discussion started by: Stellaman1977
3 Replies

2. UNIX for Dummies Questions & Answers

Research questions

Hi there, please could you assist me. I have no knowledge at all about Unix and I have applied for a job and they have given me a test and said that I can obtain the answers in any kind of way. There are 3 questions that I need answers for. I have tried researching the answers to these questions... (12 Replies)
Discussion started by: zakl
12 Replies

3. UNIX for Dummies Questions & Answers

Research an expression in VI editor

Hi, how to look for an expression like : or Client ChkAeStatus4 service in VI ? For a word , of cours : /word (2 Replies)
Discussion started by: big123456
2 Replies

4. UNIX for Dummies Questions & Answers

research proposal for PG

hi friends i have just completed my graduation and applied for Post graduation i have to submit a research proposal of OS in the interview i m a beginner & only read galvin & silbershcatz book on operating systems can anyone help me in that ... thanks in advance (3 Replies)
Discussion started by: iet.manish
3 Replies

5. Shell Programming and Scripting

Research paper library

menu should look at least like the following:- RESEARCH PAPER LIBRARY - Main Menu 0 : EXIT this program 1 : EDIT menu 2 : REPORTS Menu Enter your choice> program should check for invalid choice and display error message and re-display the main-menu. If EDIT is... (1 Reply)
Discussion started by: SHakur_BIG
1 Replies

6. Windows & DOS: Issues & Discussions

Research for College

I am researching the reasons why Unix / Linux is the chosen operating system versus Windows. I have had difficutly narrowing down resources. I am wondering if anyone has any favorite sources that they would care to share. Thanks Dan (2 Replies)
Discussion started by: isenhart
2 Replies

7. UNIX for Dummies Questions & Answers

Research paper

I am doing a "research" paper for school and i'm having a hard time finding accurate information. I am supposed to choose three differant versions of unix, give a brief explination of each, tell why there each differant from each other. I have found a ton of web sites but the information is so vast... (1 Reply)
Discussion started by: pantsusan
1 Replies

8. Forum Support Area for Unregistered Users & Account Problems

Research Project

Hi, I need you help with my research project that attempts to determine the link between users and manufacturers of IT Products such as Unix. This is part of an MBA program that I'm currently pursuing. My challenge is that I cannot possibly find out how I can send my research... (1 Reply)
Discussion started by: Tdludlu
1 Replies
Login or Register to Ask a Question