Cron - Not working properly


 
Thread Tools Search this Thread
Operating Systems HP-UX Cron - Not working properly
# 15  
Old 10-30-2007
Why to put $ ???
More over hope u remember the point "script works fine when executed manually" ....

My script is just as follows:

#!/usr/bin/sh

ZIPFILE_PATH=/...
MYLOCATION=/...

cd MYLOCATION

unzip $ZIPFILE

FILECOUNT=`ls -l | wc -l`

if [ $FILECOUNT -eq 7 ]
then
do some process
else
send an error mail


So for me, when i schedule the above script in CROn, always i do get the error mail. If i run it manually then "do some process" is happening.

what can be done ???
# 16  
Old 10-30-2007
Shouldn't the unzip command read:

unzip $ZIPFILE_PATH # here I am assuming that the ZIPFILE_PATH holds the entire path, including the filename.

I don't see you setting $ZIPFILE anywhere in the script.
# 17  
Old 10-30-2007
Quote:
Originally Posted by risshanth
Why to put $ ???
More over hope u remember the point "script works fine when executed manually" ....

My script is just as follows:

#!/usr/bin/sh

ZIPFILE_PATH=/...
MYLOCATION=/...

cd MYLOCATION

unzip $ZIPFILE

FILECOUNT=`ls -l | wc -l`

if [ $FILECOUNT -eq 7 ]
then
do some process
else
send an error mail


So for me, when i schedule the above script in CROn, always i do get the error mail. If i run it manually then "do some process" is happening.

what can be done ???
As previously said , you just need to load your login profile (.profile, .login or whatever it is) for the cron to mimic the environment you are in when you're on the shell, try that and everything should be ok.
# 18  
Old 10-30-2007
hi blowtorch,

its was a samll mistake while typing here...

its not $ZIPFILE ..
it should be

unzip $ZIPFILE_PATH
# 19  
Old 10-30-2007
hi andryk,
loading my .profile means ... i dont get you .. just executing that file or not clear .. but one thing . simple jobs scheduled in cron is working fine ..

I want to add one more point here ..

when i gave :
$whereis unzip , its showing

unzip :

So i think its not able to find the location of the unzip command.. Could this be the reason why cron is not able to execute the unzip command ??
# 20  
Old 10-30-2007
Quote:
Originally Posted by risshanth
hi andryk,
loading my .profile means ... i dont get you .. just executing that file or not clear .. but one thing . simple jobs scheduled in cron is working fine ..
Yes, the way of loading your profile in your batch is '. $HOME/.profile', there's a space between the dot and the $ (without the quote of course Smilie)

Quote:
I want to add one more point here ..

when i gave :
$whereis unzip , its showing

unzip :

So i think its not able to find the location of the unzip command.. Could this be the reason why cron is not able to execute the unzip command ??
Maybe, you may want to search for it: find /usr -name unzip -print or even from the root.

Good luck.
# 21  
Old 10-30-2007
Hi andryk,
Great .. thanks a lot .. its working ... But i want to know the reason behind this ... what is the necessity to run the .profile file ?? Kindly give me an explanation ..

Thank u so much once again ..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join not working properly

I want to join two files , with file 1 col 3 and file 2 col 1 as key. The join command is erratic for some reason. File 2 is a master file having all the names, and file 1 has some values. I want to add the names from fil2 in file 1. If I use the original master file, some output is missing. ... (16 Replies)
Discussion started by: ritakadm
16 Replies

2. Shell Programming and Scripting

Why is sort not working properly here ?

Platform: RHEL 5.4 In the below text file I have strings like following. $ cat /tmp/mytextfile.txt DISK1 DISK10 DISK101 DISK102 DISK103 DISK104 DISK105 DISK106 DISK107 DISK108 DISK109 DISK110 DISK111 DISK112 DISK113 DISK114 (8 Replies)
Discussion started by: kraljic
8 Replies

3. UNIX for Dummies Questions & Answers

~c is not working properly with -r option

Hi There, --------- file1 ------- ~c asd@ac.com -------------- Now i am using below command cat file1|mailx -s " testing" -r " My Name" abc@tech.com (3 Replies)
Discussion started by: Tapan Sharma
3 Replies

4. Red Hat

sudo is not working properly

This is the first time for using sudo for me. # visudo ## Allows people in group admin to run all commands %admin ALL=(ALL) ALL # groupadd admin # useradd temp # usermod -a -G admin temp # id temp uid=506(temp) gid=506(temp) groups=506(temp),507(admin) # #sudo... (5 Replies)
Discussion started by: getrue
5 Replies

5. UNIX for Advanced & Expert Users

Sendmail is not working properly

Hi All, Can any one help me to solve the issue. The Issue is, i have started the sendmail service on my RHEL 4 update 6 box, I am able to send the mail from my box to almost all of the Email Id's except few. Exampe, test mail. . Output is :the message is sent. now if I send the... (2 Replies)
Discussion started by: akhtar.bhat
2 Replies

6. Shell Programming and Scripting

cron does not execute script properly

I have a simple script that checks for certain printers and records them to a file. When I run the script manually at the command prompt, it works perfect, but when I run the script via cron, nothing happens. No errors reported, and no records are written out. I'm using Solaris 10. Below is the... (4 Replies)
Discussion started by: lmatlebyane
4 Replies

7. Shell Programming and Scripting

\n not working properly

Hi all, I'm trying to generate a series of txt files starting from a plain csv file part of my code: #!/bin/ksh INSTALLDIR=/Users/ME/Installdir CSV=CSV.csv TMP=/tmp/$(basename $0).txt tr -s "\r" "\n" < /$INSTALLDIR/$CSV > $TMP function Makefiles { printf '%24s:%30s\n' "sometext"... (1 Reply)
Discussion started by: Jive Spector
1 Replies

8. HP-UX

FC card not working properly

Hi I've a problem with Hp-ux 11.11 9000/800/rp3440 system. Already the software for driver & its patch are loaded for HBA Fibrechannel card, but still the fibrechannel card is showing the status "Unclaimed" . What will be reason for this? How to get the status "Claimed" ? Pl. help me out.... (4 Replies)
Discussion started by: Mike1234
4 Replies

9. UNIX for Dummies Questions & Answers

Cron won't run properly

I am new to unix, and this is my 1st post on this board. Looking for some advice about a cron job in my server. I am running a cron task that references a script which runs several other scripts and compiles them into a report and emails it to me. If I run the script manually, I will... (2 Replies)
Discussion started by: Steeler_fan
2 Replies

10. Programming

y is this not working properly?

#include <stdio.h> #include <sys/types.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> struct stat s; main() { char c; if (fork()==0) { system("clear"); do { printf("myAI\\> "); scanf("%s",c); if(stat(c,&s)>-1) {... (3 Replies)
Discussion started by: C|[anti-trust]
3 Replies
Login or Register to Ask a Question