- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Simple find command
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
12-20-2005 04:57 AM
12-20-2005 04:57 AM
I have a simple script to copy oracle dumps
across a nfs mount to another server that is offsite. Here is is.
#!/bin/sh
DATE=$(date +%m%d)0700
touch -t $DATE /tmp/reffile
find /usr/local/dumps -type f -name *.gz -newer /tmp/reffile -exec cp {} /offsite_mnt \;
sleep 5
rm -f /tmp/reffile
The find command is all on one line.
In the actual script I use full paths for all commands. but when I run it It comes back with:
/usr/bin/find: paths must precede expression
Usage: /usr/bin/find [path...] [expression]
Any Ideas ? I am loosing hair over this.
TIA
Paul
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 05:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 05:13 AM
12-20-2005 05:13 AM
Re: Simple find command
I guess linux find is slightly different than HP-UX. Thanks again and happy hollidays
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 05:19 AM
12-20-2005 05:19 AM
Re: Simple find command
Therefore you get the error you see. You should either escape any shell metacharacters in the -name argument or enclose that argument in quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2005 05:24 AM
12-20-2005 05:24 AM
Re: Simple find command
Thanks for the clearification.
Happy Hollidays
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2005 07:15 AM
12-29-2005 07:15 AM
Re: Simple find command
Well the script works fine when I run it from the command line. But when I try to schedual it in cron it doesn't work. No clues in the cron log or messages file.
the cron log shows it runs for 6 seconds
(sleep 5 + 1 sec) so my guess is the find is not working. Any ideas
TIA
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2005 08:03 AM
12-29-2005 08:03 AM
Re: Simple find command
anyway I suggest you to provide the full path of an executable in crontab.This executable would be a bash script with one command.In your case the find command.If it works-great!Otherwise try other simpler commands like "touch /tmp/filename". Isolate the problem in other words...
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2005 11:11 PM
12-29-2005 11:11 PM
Re: Simple find command
Another way to debug is to redirect the ouput of the command to a log file, if this script is called clean.bash, configure your cron to run to something like this:
5 * * * * /usr/local/sbin/clean.bash > /var/log/clean.log 2>&1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2005 06:39 AM
12-30-2005 06:39 AM
Re: Simple find command
Thanks for the help, I am more of a HP-UX guy than a linux person. At any rate I finally got it working. For some reason I had to start and stop cron in order to get the log file to be created and the script worked. (0 byte logfile) I decided to stop logging the job and the thing quit working so I stopped and started cron again and the job worked again. So it seems that any time I make any changes to my cron jobs I have to restart crond. Something I never have to do in HP-UX. Or maybe my Linux server is flakey?
Once again thanks for your help
And Happy New Years to All.
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2005 06:52 AM
12-30-2005 06:52 AM
Re: Simple find command
You only need to restart cron when you clean the cron log file (/var/log/cron), so cron can write to the file again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2005 07:09 AM
12-30-2005 07:09 AM
Re: Simple find command
Yes I was using crontab -e to edit my cron jobs. But honestly any time I changed my job it quit working untill I restarted crond.
Makes no sence to me but I am glad to hear this isn't a "normal" thing to have to do.
Perhaps I am behind on patches. We are mostly a HP-UX and windows operation but are favoring Linux over Windows for any new servers.
Thanks again
Happy New Years To All
Paul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2006 08:18 PM
01-01-2006 08:18 PM
Re: Simple find command
#!/bin/sh
# Script
touch -t $(date +%m%d)0700 /tmp/reffile
# Will go to cron log
echo "Operation is Started :)"
for file in `find /usr/local/dumps -name "*.gz" -type f -newer /tmp/reffile`
do
cp ${file} /offsite_mnt;
done
sleep 1
rm -f /tmp/reffile
# Will go to cron log
echo "Operation is completed :)"
#END
exit 0
Edit crontab -e as,
5 * * * * path to script
and monitor cron log and post the result.
-Muthu