- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cron based find command problems
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:30 AM
06-12-2003 05:30 AM
cron based find command problems
I have a script running from cron, on an L3000 (dual CPU) under HP-UX 11.11, which executes the following code
cd $ARCHIVEDIR
for file in `find . -name "*.dbf" -mtime +1 -print`
do
echo "Processing file $file"
/usr/contrib/bin/gzip $file
done
For some reason, the find command does not bring back any files.
Looking in a log, with debugging enabled, I get
+ cd /oradata1/archive/SCP01
+ find . -name *.dbf -mtime +1 -print
so it's resolving the value of $ARCHIVEDIR correctly.
Running the command manually, I get files listed.
./1_1431.dbf
./1_1432.dbf
./1_1433.dbf
./1_1434.dbf
./1_1435.dbf
./1_1436.dbf
./1_1437.dbf
./1_1438.dbf
./1_1439.dbf
./1_1440.dbf
./1_1441.dbf
./1_1442.dbf
./1_1443.dbf
Initially, I was using find . -name "*.dbf" -mtime +1 -exec /usr/contrib/bin/gzip {} \;
but that was also not working
( I switched to the loop to try to get to the bottom of the issue)
Trying the find without the -mtime option (not gzipping this time as I don't want to risk damaging my current files) I get the files displayed - aha you may think, something wrong with the mtime option, however, when using -mtime +1 without giving a filename, the files that have already been gzipped in that directory are displayed.
The files are not in use by another process (at least fuser reports nothing) and can be manually zipped with no errors.
So what can it be that causes find to work correctly with either a name, or an mtime option with no problems, but to only partially work when both are specified?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:33 AM
06-12-2003 05:33 AM
Re: cron based find command problems
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:47 AM
06-12-2003 05:47 AM
Re: cron based find command problems
I have done the following :
#!/usr/bin/ksh
cd /tmp
for i in `find . -name \*.dbf -mtime +1 -print`
do
echo "Hello $i"
done
created two files 1.dbf and 2.dbf. Nothing got printed until I removed the mtime option. So everything works fine.
I must strongly advise to not use any variables in a cron driven script. These vars should be known my the executor from cron. Please use a realdir-name instead of a var. It should definitly work than.
Regs David
B.T.W. know that you are displaying files older than 1 day. I asume the files are older than one day ? :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:52 AM
06-12-2003 05:52 AM
Re: cron based find command problems
This will evaluate the search template "*.dbf". What I do in this case is twofold,...
No quotes around the search criteria
Escape Char (\) before every occurence of a search character like $*[]() and .
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:53 AM
06-12-2003 05:53 AM
Re: cron based find command problems
I suspect it's the old cron's environment answer. Your $ARCHIVEDIR is not set. Either source an environment script when setting up cron jobs, or use full path names and explicitly set any variables.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:54 AM
06-12-2003 05:54 AM
Re: cron based find command problems
I tried it on my system with -name AND -mtime +1 and I can't make it fail ... I even tried from cron and it still works. I also looked for a patch but nothing concerns your problem.
Do you really launch exacly this script from your crontab ?
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 05:58 AM
06-12-2003 05:58 AM
Re: cron based find command problems
Please disregard my ill-advised and uninformed prior answer. I'm still working on my reading skills.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:08 AM
06-12-2003 06:08 AM
Re: cron based find command problems
for file in `find . -mtime +1 -print | grep \.dbf$`
For debugging, try echoing $ARCHIVEDIR to a file, along with the output of the find command by itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:10 AM
06-12-2003 06:10 AM
Re: cron based find command problems
your code works on my system as well!
But I do not personally like the use of the word "file", as I have the idea it could conflict with the built-in function of the same name. However, it apparently does not disturb my shell - could it be disturbing yours?
Far out, but...
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:13 AM
06-12-2003 06:13 AM
Re: cron based find command problems
find . -name *.dbf -mtime +1 -print {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:14 AM
06-12-2003 06:14 AM
Re: cron based find command problems
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:22 AM
06-12-2003 06:22 AM
Re: cron based find command problems
find . -name \*.bdf -exec gzip {}\;
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 06:48 AM
06-12-2003 06:48 AM
Re: cron based find command problems
maybe simple, but with which user are you executing the cron command ? the same as in interative mode ?
Is there any customization in the /var/adm/cron/.proto that may prevent the proper work ?
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2003 07:13 AM
06-12-2003 07:13 AM
Re: cron based find command problems
three points:
1. is your script using find, or /usr/bin/find?
2. Did you think of putting the mandatory #/usr/bin/ksh at the beginning of the script?
3. did you actually put the double quotes around "*.dbf" ?
I have run some tests on my system, and the script ran fine as long as I had thought of the three points above...
On the other hand, trying to launch the command on the crontab without putting it in a script failed, because cron uses the posix shell and not the kron shell...
Cheers,
FiX