"No such file or directory" while running crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users "No such file or directory" while running crontab
# 1  
Old 10-05-2012
"No such file or directory" while running crontab

I am trying to take backup of server. while running manually, script working successfully.
while running in crontab its showing
Code:
"/bin/sh: /webMethod6/CustomMonitoring/scripts/backupWebMethodsCodeBase.sh: No such file or directory"
code forbackupWebMethodsCodeBase.sh

#!/bin/ksh

#Purpose : To backup webMethods Installation on a given server for quick 
#          restoration of  a corrupt server scenario 
#         Excludes un-necessary folders example SharedTempArea logs pipeline etc
#

set -a 

host=`/bin/hostname`
DateAsStr=` /bin/date  "+%m_%d_%Y"` 

echo "`date`  Backup of webMethods6 started on Host $host "  

if [[ $# -eq 1 ]] then
   BASE_DIR=$1

 if [[ ! -d $1 ]] then
  echo "Script $0 : Directory Doesn't exists. Valid webMethods Directory is required to proceed further.  Input $1. "
 exit 1
 fi 

else
 #default to webMethods6
 BASE_DIR="/webMethods6"

fi 

if [[ ! -d $BASE_DIR/custombackup ]] then 
 mkdir $BASE_DIR/custombackup 
else 
 #remove any old files 
 rm -f $BASE_DIR/custombackup/*.*
fi  

IS_DIR="$BASE_DIR/IntegrationServer"
onlyBaseName="`/usr/bin/basename $BASE_DIR`"
isroot_fileName="$BASE_DIR/custombackup/${onlyBaseName}_IS_${host}_$DateAsStr.tar.z"
webMroot_fileName="$BASE_DIR/custombackup/${onlyBaseName}_root_${host}_$DateAsStr.tar.z"

echo "`date` Tar webMethods6 Root folder as $webMroot_fileName  " 
cd $BASE_DIR

webMHomeList=`find . -maxdepth 1 -type d | grep -v wMbackupOld | grep -v WmPackagesTEST_20111202 | grep -v wMtest_bckup_20111202 | grep -v Ima
ge | grep -v Backup_20110702 | grep -v installer | grep -v custombackup | grep -v IntegrationServer | grep -v CustomMonitoring  | grep -v tspa
ceLocation | grep -v installer | grep -v install | grep -v tmp | grep -v configData | grep -v TNBackupData | grep -v lost | grep -v jvm  | tr 
-d '.' | tr -d '/' `

echo $webMHomeList 
nice tar -czf $webMroot_fileName $webMHomeList  

echo "`date` Tar webMethods6 IS Folder as  $isroot_fileName  "

cd $IS_DIR

webM_ISList=`find . -maxdepth 1 -type d | grep -v packages_2dec | grep -v DocumentStore_back | grep -v SharedTempArea | grep -v pipeline  | gr
ep -v logs | grep -v userFtpRoot | grep -v configData | grep -v TNBackupData |  tr -d '.' | tr -d '/' `

echo $webM_ISList 
nice tar -czf $isroot_fileName $webM_ISList  

echo "`date` Transfering $isroot_fileName "
. /webMethods6/CustomMonitoring/scripts/ftpToWindows1.sh  $isroot_fileName  $1

echo "`date` Transfering $webMroot_fileName "
. /webMethods6/CustomMonitoring/scripts/ftpToWindows1.sh  $webMroot_fileName $1

echo "`date`  Backup of webMethods6 completed "

Please Help me

Last edited by Scott; 10-05-2012 at 05:01 AM.. Reason: Code tags, please...
# 2  
Old 10-05-2012
Quote:
Originally Posted by elango963
while running in crontab its showing

"/bin/sh: /webMethod6/CustomMonitoring/scripts/backupWebMethodsCodeBase.sh: No such file or directory"
code forbackupWebMethodsCodeBase.sh
Are you giving right path for the script in crontab..??

one more thing in noticed in your script..
you don't need so many grep -v just use egrep or grep -E
Code:
egrep -v "installer|custombackup|IntegrationServer"

grep -v -E "installer|custombackup|IntegrationServer"

# 3  
Old 10-05-2012
"No such file or directory" while running crontab

Thank u for ur reply.
yes I am giving correct path only

this is the path i am giving in crontab
Code:
0 9 5 * * /webMethod6/CustomMonitoring/scripts/backupWebMethodsCodeBase.sh /webMethods6 >> /webMethods6/CustomMonitoring/logfiles/crontab/backupWebMethodsCodeBase.log 2>&1

Moderator's Comments:
Mod Comment Please use code tags Image

Last edited by Scott; 10-05-2012 at 05:02 AM.. Reason: Code tags
# 4  
Old 10-05-2012
not sure what could be the issue..Smilie

wild guess.. try

change #!/bin/ksh to #!/bin/shor #!/bin/bash
# 5  
Old 10-05-2012
If /bin/sh is complaining, then it's not getting to the shebang in his script at all yet.

Are you absolutely 100% positive that there's no typos? I hate capitalizedletterExceptTheVeryFirstTwoOrThree file and function names because they're so easy to mess up, and so difficult to tell when you do.

Run it using absolute path in your shell and copy-paste the path into your crontab.
# 6  
Old 10-12-2012
I tried with all
Code:
 #!/bin/ksh

Code:
 #!/bin/sh

Code:
 #!/bin/bash

same error getting
also i copied program with other name.this time also while running manually its working
but in crontab its not working
Please give me any more idea
Thanks for reply.
# 7  
Old 10-12-2012
I don't see you setting your environment anywhere in this script, so i suppose it doesn't have one. You probably fell for "Cron Problem Number One".

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

Problem with running the "autorep" command via crontab

Hi, The user "MadeInGermany" tried to help on the below post by saying "This has been asked before; see the links below. Get your current LD_LIBRARY_PATH and redefine that in your ksh script! " Thanks for the help. but this did not help. And my post got locked. I can't reply on my previous... (5 Replies)
Discussion started by: girish1428
5 Replies

5. UNIX for Dummies Questions & Answers

Scripts exists but crontab says "File not found"

Hi All, We have an archiving script on our applications box. It is scheduled to run at 36th minute every hour. 36 * * * * /archive_7.sh But it throws an error saying "sh: /archive_7.sh: not found". I am not able to understand why. # ls -l /archive_7.sh ; file /archive_7.sh -rwxr-xr-x ... (4 Replies)
Discussion started by: satish51392111
4 Replies

6. Shell Programming and Scripting

"find . -printf" without prepended "." path? Getting path to current working directory?

If I enter (simplified): find . -printf "%p\n" then all files in the output are prepended by a "." like ./local/share/test23.log How can achieve that a.) the leading "./" is omitted and/or b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
Discussion started by: pstein
1 Replies

7. Shell Programming and Scripting

Crontab not running "nail" in script

the script is in Perl... this is one part of it: $command = "echo \"$text\" | /usr/bin/nail -s \"My $text1\" $ccstr$addstr"; system("$command") if length($bodytext)>1; crontab runs the script and sends me notifications but i cant receive any mail that i wanted! I'm using the complete path... (1 Reply)
Discussion started by: yeean
1 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. Shell Programming and Scripting

Delete files older than "x" if directory size is greater than "y"

I wrote a script to delete files which are older than "x" days, if the size of the directory is greater than "y" #!/bin/bash du -hs $1 while read SIZE ENTRY do if ; then find $1 -mtime +$2 -exec rm -f {} \; echo "Files older than $2 days deleted" else echo "free Space available"... (4 Replies)
Discussion started by: JamesCarter
4 Replies

10. HP-UX

script running with "ksh" dumping core but not with "sh"

Hi, I have small script written in korn shell. When it is called from different script, its dumping core, but no core dump when we run it standalone. And its not dumping core if we run the script using "/bin/sh" instead of "ksh" Can some body please help me how to resolve this issue. ... (9 Replies)
Discussion started by: simhe02
9 Replies
Login or Register to Ask a Question