Find command fails in crontab


 
Thread Tools Search this Thread
Operating Systems AIX Find command fails in crontab
# 1  
Old 10-05-2010
Data Find command fails in crontab

Hi ,
I imported find command I have on my hp-ux server to clean up the /tmp of my new IBM AIX servers.
Though, the commands always fails in the cron but if I past it at the prompt, it works find. I tried with at jobs and regular 'find' .

Could anyone tell me what I am doing wrong?

Many thanks

Here is part of my crontab:
Code:
1    0,12  *   *   *   find /tmp -name "*\.model" -type f -mtime +1 -exec rm {} \;
0    0,12   *   *   *  find /tmp -name "*.catrace.*.log" -type f -mtime +1 -exec rm {} \;
16   0,12   *   *   *   find /tmp -name *.web* -type f -mtime +1 -exec rm {} \;
16   0,12   *   *   *   echo "find /tmp -name \"*.web*\" -type f -mtime +1 -exec rm {} \;"| at now

Moderator's Comments:
Mod Comment Use code tags please, ty.

Last edited by zaxxon; 10-05-2010 at 10:04 AM..
# 2  
Old 10-05-2010
have you tried incorporating your functionality in a script and then scheduling the script in cron....???
# 3  
Old 10-05-2010
Bug

No I did not. I will and let you know.
Thanks very much.

---------- Post updated at 07:36 AM ---------- Previous update was at 06:09 AM ----------

It worked. Thanks for your help.
# 4  
Old 10-05-2010
it would most likely work as well if you would mention the location of find - like
Code:
1 0,12 * * * /usr/bin/find /tmp -name "*\.model" -type f -mtime +1 -exec rm {} \;

Regards
zxmaus
# 5  
Old 10-06-2010
In cron... always use absolute paths for all commands, and file paths...

for find command you have to use.
also for the rm command use absolute path.

Last edited by thegeek; 10-06-2010 at 07:42 AM.. Reason: missed to mention in cron, which is important
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command works on Linux but fails on Solaris.

Hi, I am looking for a generic find command that works on both Linux and Solaris. I have the below command that works fine on Linux but fails on solaris.find /web/config -type f '(' -name '*.txt' -or -name '*.xml' -name '*.pro' ')' Fails on SunOS mysolaris 5.10 Generic_150400-61 sun4v sparc... (1 Reply)
Discussion started by: mohtashims
1 Replies

2. Shell Programming and Scripting

Need to know why crontab -e fails

more cron.txt 1 * * * * /u/ways.sh 2>&1 >/dev/null bash-4.1$ export EDITOR=vi bash-4.1$ crontab -e <cron.txt Vim: Warning: Input is not from a terminal Vim: Error reading input, exiting... Vim: Finished. The crontab file was not changed. bash-4.1$ echo $? 1 bash-4.1$ uname -a SunOS... (3 Replies)
Discussion started by: mohtashims
3 Replies

3. Shell Programming and Scripting

find command fails mid-way during execution

I wish to search for a particular string say "Yellow_Colors" in all files in all folders in the current directory. Below is the command I use: find ./ -type f | xargs grep -i "Yello_Colors"However, my command does not traverse all files and folders and errors out mid-way with the below error... (7 Replies)
Discussion started by: mohtashims
7 Replies

4. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

5. Shell Programming and Scripting

Script won't fails when running from crontab

Hi, My script runs fine from the command line, but when crontab tries to launch it encounters lack of permissions: could not open /dev/kbd to get keyboard type US keyboard assumed could not get keyboard type US keyboard assumed split: Permission denied This is the head of the script: ... (2 Replies)
Discussion started by: Cvg
2 Replies

6. UNIX for Dummies Questions & Answers

Find command fails when a space is in the directory path variable

I have a script like this running under OS X 10.8. The problem arises when the find command encounters a space in the path name. I need the "dir" variable as I'll be extending the script to more general use. #!/bin/bash CFS=$IFS IFS=$(echo) set dir = "/Users/apta/Library/Mail\... (3 Replies)
Discussion started by: apta
3 Replies

7. Shell Programming and Scripting

SH script, variable built command fails, but works at command line

I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes CC=`which gcc` CONFIGopt=' --prefix=/ --exec-prefix=/usr... (8 Replies)
Discussion started by: oly_r
8 Replies

8. Programming

SFTP fails from crontab but works from terminal

Dear community, I'm driving crazy with a strange issue. I have a simple script to transfer a file to a remote system:#!/bin/bash echo "put /tmp/server.log" > /tmp/server1_transfer.sftp sftp -b /tmp/server1_transfer.sftp user@10.99.1.2:Between client and server there is a SSH KEY, so if I run... (15 Replies)
Discussion started by: Lord Spectre
15 Replies

9. Shell Programming and Scripting

Need help! command working ok when executed in command line, but fails when run inside a script!

Hi everyone, when executing this command in unix: echo "WM7 Fatal Alerts:", $(cat query1.txt) > a.csvIt works fine, but running this command in a shell script gives an error saying that there's a syntax error. here is content of my script: tdbsrvr$ vi hc.sh "hc.sh" 22 lines, 509... (4 Replies)
Discussion started by: 4dirk1
4 Replies

10. Shell Programming and Scripting

crontab fails to run script

OS is Ubuntu 8.04.3. When I run the command: /usr/bin/syslogMailer < /etc/syslog.pipes/criticalMessagesFrom a bash shell it works and i receive an email as per the script however when run from crontab it does not work. Can anyone explain why and how to fix it? /usr/bin/syslogMailer... (4 Replies)
Discussion started by: jelloir
4 Replies
Login or Register to Ask a Question