Script ran by job scheduler fails from the 15th to the 20th of the month


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script ran by job scheduler fails from the 15th to the 20th of the month
# 1  
Old 02-06-2009
Question Script ran by job scheduler fails from the 15th to the 20th of the month

Hi,

I have a script that finds the application logs from the previous day and sends it to another server via ftp.
The code is something like this:
yest_date=`TZ=CST+24 date "+%b %d"`
logdir=/app/logs
logs=app*.log
tmpdir=/tmp
cd $logdir
for i in `ls -1 $logs`
do
chkstr=`ls -1l $i | grep "$yest_date"
if [ "$chkstr" != "" ]
then
tar -cvf $tmp/$yest_date-logs.tar $file



The script works fine when ran manually and via cron. But when ran through a job scheduler, UC4, the script fails every 15th - 20th of the month! Consistently! It looks like from the script log, the code just did not execute. The log shows that it cannot find the .tar file when it attempted to ftp.
My OS is AIX and shell is Korn shell. The job scheduler uses the same login as when I execute the script manually or when ran thru cron. The AIX admins found no processes/jobs that could affect the script execution. What else could I check? Any ideas is much appreciated! Smilie
# 2  
Old 02-09-2009
how many log files are in there? lots and lots and lots?

if so:

for i in `ls -1 $logs`

might be giving "arglist too long error"

are you seeing any errors in the UC4 execution logs?

If not - - - then the problem is probably NOT your script and
is most likely something in UC4.
# 3  
Old 02-09-2009
chkstr=`ls -1l $i | grep "$yest_date"`
There is a backtick missing on this line.

Design point: Does the filename contain the date (MMM DD) , or are you looking for the date in the directory listing? ls minus one .. or ls minus ell ?


There are many continuity and syntax errors in the script as posted.

It sets $tmpdir , then uses $tmp .
Where is $file set ?
for ... do ... done
if ... then ... fi
Variable $i will not work if the filename(s) contain spaces.

Please post the actual script !
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Autosys Scheduler- Running job at particular time

Hi Experts, I am new to Autosys. I created a Autosys box job to run at 10 AM daily. As scheduled, the job starts on time. There is another box job inside the box. I have scheduled it to run at 11 AM but it kicks off automatically with the main job at 10 AM. insert_job: Main-job ... (2 Replies)
Discussion started by: pk_bohra
2 Replies

2. Shell Programming and Scripting

Unexpected EOF while looking for matching `'' when ran from a cron job

Since cPanel does not support deleting emails older then X amount of days I am using the following on a Cron Job. find -P /home/user/mail/domain/ -mindepth 2 -mtime '+366' -type f -printf '"%p"\n' | grep -v '/Important' | grep -v '/.Important' | xargs -I {} rm -r "{}" Executing it via SSH... (4 Replies)
Discussion started by: tiagom
4 Replies

3. Shell Programming and Scripting

Crontab job scheduler problem

Dear All. I have a scripts which does many task like house keeping, moving file to different location and loading the data into oracle. I run this scripts daliy manually , I decided to put it into cron. I have put the scripts into crantab but the behaviour of the scripts have changed. it... (2 Replies)
Discussion started by: guddu_12
2 Replies

4. Shell Programming and Scripting

Help needed regarding cron job scheduler with CyberArk Password security

Hi All, I have a script which will restart some web server and bring it up again. For that I need to retrieve 3 password from CyberArk (Cyber-Ark - Wikipedia, the free encyclopedia) vault. My question is: Is this possible to schedule the script through cron and automatic password... (0 Replies)
Discussion started by: saps19
0 Replies

5. UNIX for Advanced & Expert Users

How to identify the scripts ran at a particular day of last month?

How to identify the scripts ran at a particular day of last month? I have to identify a script that ran on 06/01/2011 @ 4 am (3 Replies)
Discussion started by: rdhanek
3 Replies

6. UNIX for Advanced & Expert Users

Cron job fails every now and then.

I added a shell script to cron that executes every 5-15 minutes. It's used to monitor multiple environments, so it has to ssh to each machine to check the status of that machine. Sometimes, I may have more than one instance of this script running at the same time. So, here's my problem. I've... (2 Replies)
Discussion started by: mrwatkin
2 Replies

7. Shell Programming and Scripting

how can I reschedule a job if it fails

i have a sql script ex a.sql i want to schudle it at 1 am every day if it fails then it wiil run after 2 haours can some one help me write a shell script for this problem??????????? (1 Reply)
Discussion started by: alokjyotibal
1 Replies

8. Shell Programming and Scripting

Job scheduler without using cron

Hi, I want to schedule the scripts/batches to run simultaneously. I had all the information in the config (flat)file, which contains script name, time, dependency, path, priority and status etc., I want to run the jobs parellelly and some jobs are required to give the input. How can I do this?... (1 Reply)
Discussion started by: sharif
1 Replies

9. UNIX for Advanced & Expert Users

Job Scheduler Agent-Based.

Hi Gurus, I'm looking for a real Jobs Scheduler Agent-based. My customer is using cron, but need something a little bit clever, where you could configure chain of process ("script x will run if script y is finished", etc). Of course I know solutions like control-M (from BMC... (1 Reply)
Discussion started by: maquinte
1 Replies
Login or Register to Ask a Question