![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| root executes a script as another user | ravi.sri24 | Shell Programming and Scripting | 9 | 02-11-2009 10:43 AM |
| Script is not working when put in crontab | *Jess* | Shell Programming and Scripting | 2 | 11-26-2008 02:05 AM |
| shell script executes program, but waits for a prompt | lionatucla | Shell Programming and Scripting | 7 | 06-19-2008 04:10 AM |
| crontab and shell script that executes a sql. | radhika | Shell Programming and Scripting | 6 | 06-07-2005 12:33 AM |
| root executes a script as another user | tads98 | Shell Programming and Scripting | 1 | 05-17-2005 09:54 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
script not working from crontab, executes individual
Hi,
This script is working successfully when i executed from shell prompt, but the same script scheduled in crontab its not deleting the files, #! /bin/bash DAY_1=`(date --date='4 months ago' '+%Y-%m')` log=/tmp/cleant adir=/u01/app/oracle/admin/talon/adump udir=/u01/app/oracle/admin/talon/udump bdir=/u01/app/oracle/admin/talon/bdump export DAY_1 echo "Cleaning trace files start " > $log date >>$log echo $DAY_1 >>$log cd $adir ls -l | grep -i $DAY_1 | awk '{ print $8}'| xargs rm -f cd $udir ls -l |grep -i $DAY_1 | awk '{print $8}'| xargs rm -f cd $bdir ls -l |grep -i $DAY_1 | awk '{print $8}'| xargs rm -f cd echo "Finished " >>$log i am trying to remove files 4 months ago which would be in huge number(500000 approx. files). if run $ . remtrc ( it successfully removes files) crontab (example) 10 00 1 * * * /home/oracle/remtrc > /tmp/cleantrc.log but from crontab it not able to remove files. what i am missing in the script. |
|
||||
|
Well, you need to handle the output stream that goes to stderr: Code:
10 00 1 * * * /home/oracle/remtrc > /tmp/cleantrc.log 2>&1 see: Redirecting to and from the standard file handles |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|