Shell script stop working


 
Thread Tools Search this Thread
Operating Systems AIX Shell script stop working
# 1  
Old 07-11-2010
Shell script stop working

I have a strange problem.

I have the following in a cron to find files older than a day.

Code:
find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w

It was working fine for the last few days now it suddenly stopped working. I can clearly see files in the directory that is older than a day, but the command is suddenly reporting zero. Is there something wrong with the OS?
# 2  
Old 07-11-2010
No. The OS is fine.

Something in the envrionment changed

Code:
find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w 2&>1 > /mypath/to/log/cron.log

read the cron.log file to find your problem.
# 3  
Old 07-11-2010
Have you checked you're mail on the AIXbox, as cron outputs it's logging in the users mailbox.
# 4  
Old 07-12-2010
Quote:
Originally Posted by jim mcnamara
No. The OS is fine.

Something in the envrionment changed

Code:
find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w 2&>1 > /mypath/to/log/cron.log

read the cron.log file to find your problem.

The log file just shows the task executed successfully. Not errors. But I can clearly see files from June sitting in the directory. Why isn't it picking those up?

---------- Post updated at 06:08 PM ---------- Previous update was at 06:08 PM ----------

Quote:
Originally Posted by raba
Have you checked you're mail on the AIXbox, as cron outputs it's logging in the users mailbox.
Nothing in mail.
# 5  
Old 07-13-2010
Quote:
Originally Posted by jim mcnamara
No. The OS is fine.

Something in the envrionment changed

Code:
find /dir1/dir2/ ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \; | wc -w 2&>1 > /mypath/to/log/cron.log

read the cron.log file to find your problem.
change this line after the pipe to:

Quote:
wc -w >/mypath/to/log/cron.log 2>&1


Edit: the problem is the prune command,
your first folder, dir2, is a directory, so find stops

write a script like that:

Code:
#!/usr/bin/ksh
cd /dir1/dir2/
find . ! -name . -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \;

or change the command to:

Code:
find /dir1/dir2 ! -name dir2 -prune -name "s*.txt" -type f -mtime +1 -exec echo {} \;

from the man page of find:

Quote:
-prune
Always evaluates to the value True. Stops the descent of the current path name if it is a directory. If the -depth flag is specified, the -prune flag is ignored.

Last edited by funksen; 07-13-2010 at 04:41 AM..
# 6  
Old 07-13-2010
Ok.

The change you recommended worked but why? It was working all along just fine as it was, then suddenly stopped. When I make the change you suggested, it's working agin. How strange.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to stop a shell script if it encounters a error?

I am writing a bash shell script for GarazLab's "WP EMAIL CRAWLER - AUTO SCRAPER & REAL TIME EXTRACTOR". it contains some commands. I want to stop the shell execution as soon as it encounters an error. how to do it? (8 Replies)
Discussion started by: tahsin352
8 Replies

2. Shell Programming and Scripting

Shell script to stop and start server

Hi, I need to create a shell script for automated server patching, with the following scenario: I have two Linux servers Primary and secondary. Server patching should start on Primary 1st and then secondary. 1st check both servers are up and running. Then stop primary and patching will... (1 Reply)
Discussion started by: rcroyal88
1 Replies

3. Shell Programming and Scripting

Password in shell script for apps stop

Hi folks, I am running a shell script it asks for username and password to stop some service, I need to write some script that it will read username and password from my shell script and then sucessfully stop services without prompting username/password query. (13 Replies)
Discussion started by: learnbash
13 Replies

4. AIX

AIX stop script not working

I have a AIX stop script file "stop_service_mail_DE_P" which is as follwoing ( if then sleepforvalue=$(cat stopfileparam|grep sleepperiod|awk -F= '{print $2}') targetdir=$(cat stopfileparam|grep targetdir|awk -F= '{print $2}') touch $targetdir/stop_b2bgate_service_mail_de_p_p sleep... (1 Reply)
Discussion started by: yashoda avvaru
1 Replies

5. Shell Programming and Scripting

Stop! (the countdown!) :-) shell script help

Hi guys, I've found two nifty little scripts on these forums one which detects if the F5 key has been pressed: #/bin/sh _key() { local kp ESC=$'\e' _KEY= read -d '' -sn1 _KEY case $_KEY in "$ESC") while read -d '' -sn1 -t1 kp do _KEY=$_KEY$kp ... (0 Replies)
Discussion started by: rich@ardz
0 Replies

6. Shell Programming and Scripting

Help with stop/start Shell Script.

Hi All, I would like to develop a shell script for stop & start an application server (1-4) on Solaris box. Here are the user requirements for this task. 1. User will input the option which server they wish to stop. 2. Will clear cache files from specific location. 3. ... (1 Reply)
Discussion started by: venga
1 Replies

7. Shell Programming and Scripting

How to stop asking password while running shell script?

Hello, I am ftping the file from one unix box to another box. This script works fine. Only problem here is, it is asking the password when ftp the file. How can i stop that. I am providing the password inside the shell script. But it is not accepting this. I need to put this script in crontab.... (5 Replies)
Discussion started by: govindts
5 Replies

8. UNIX for Dummies Questions & Answers

Anyone know?: How the 'for'-loop could stop working in interactive bash shell?!

It is happening with my sessions already second time: a 'for'-loop for some reason stop to work as expected. That means or it is looping without exitting, or it is not loop even once. Here example of my try when it is not processing even one loop. You can see, I start new subshell and... (14 Replies)
Discussion started by: alex_5161
14 Replies

9. UNIX for Dummies Questions & Answers

Stop a shell script

Hi, I am writing a bash shell script. How can I tell it to stop. For example, I would like to have something similar to the following: mike=1 if ; then STOP THE SCRIPT fi (3 Replies)
Discussion started by: msb65
3 Replies

10. Shell Programming and Scripting

stop Prstat using shell script

How to stop the Prstat using shell script ? because after i run the below script the thing seems to be always in loop and cannot get out till i ctrl + c, is there anything that i can add in the script to make it terminate ? <code> #!/bin/sh prstat -Tc -u testing > testing.txt </code> ... (19 Replies)
Discussion started by: filthymonk
19 Replies
Login or Register to Ask a Question