- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Cron Job Issue
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
02-23-2010 04:09 AM
02-23-2010 04:09 AM
We have created one script to collect recent files(when this script executed, it will check less than one hour time stamp files) and zip that files and transfer to other server.
When i run the script manually, it is working properly.
I tried with cron job. But it is not taking any files & zip file is created with 0 bytes and transferred to other server.
I am confusing why it is not executing with correct output only in cron job.
Kindly clarify on this.
Thanks in Advance
Shameem
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:13 AM
02-23-2010 04:13 AM
Solutioncheck on the "cron logs" to send some light on your problem
/var/adm/cron/log ? and also it could better if you can post "entry of your crontab" and location of the script which you are calling
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:13 AM
02-23-2010 04:13 AM
Re: Cron Job Issue
Try to set up in your srcipt the shell you are using and set the PATH variable (copy the value from profile)
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:20 AM
02-23-2010 04:20 AM
Re: Cron Job Issue
Find cron entry. i changed the time now for testing.
50 14 * * * /home/eppadm/scripts/epp-sync-j2ee-daily.sh
Log file information below.
> root 6826 c Tue Feb 23 14:50:00 WAT 2010
> CMD: /home/eppadm/scripts/epp-sync-j2ee-daily.sh
> root 6827 c Tue Feb 23 14:50:00 WAT 2010
< root 6825 c Tue Feb 23 14:50:00 WAT 2010
< root 6826 c Tue Feb 23 14:50:01 WAT 2010
< root 6827 c Tue Feb 23 14:51:18 WAT 2010
#!/bin/sh shell information updated in the script.
Which PATH variable need to set?
Kindly check and provide your feedback.
Thanks in Advance
Shameem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:20 AM
02-23-2010 04:20 AM
Re: Cron Job Issue
Looks like environment and PATH for the commands in your script is not defined.
Define it PATH variable in your script or replace each command with its absolute path.
Regards!
Johnson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:21 AM
02-23-2010 04:21 AM
Re: Cron Job Issue
/home/eppadm/scripts/epp-sync-j2ee-daily.sh
And define the PATH in there (get it from profile)
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:22 AM
02-23-2010 04:22 AM
Re: Cron Job Issue
Also check for the absolute path of the script in your crontab.
Check for the permission of the script/file & the directory structure.should have execute permission for the script file for the owner of the sript/file.
Rgds.,
Sachin Kumbla.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:22 AM
02-23-2010 04:22 AM
Re: Cron Job Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:24 AM
02-23-2010 04:24 AM
Re: Cron Job Issue
#
PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:.....
Copy the value from your user's profile.
Horia
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 04:58 AM
02-23-2010 04:58 AM
Re: Cron Job Issue
I updated PATH. i have taken path details from /etc/profile.
Still it is not working... Again i am telling this script is working properly when i execute manually :).
I have attached script in the attachment.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 05:03 AM
02-23-2010 05:03 AM
Re: Cron Job Issue
Not good enough...
As the user you are running "manually" the script and it is working, do
set
and copy PATH line
Then open your script and past the line there (delete this line)
I believe the only problem is with gzip but just to be sure, add the correct PATH variable as above.
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 05:06 AM
02-23-2010 05:06 AM
Re: Cron Job Issue
I assume it is an IP address, not some variable?
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 05:06 AM
02-23-2010 05:06 AM
Re: Cron Job Issue
set pathname
and than try
Good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 05:28 AM
02-23-2010 05:28 AM
Re: Cron Job Issue
>>IP address<< as per IP attachment have exculded, becoz its confidential ..?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 08:58 PM
02-23-2010 08:58 PM
Re: Cron Job Issue
I removed IP & server name from the script and uploaded to ITRC :)
If I set a path using set command, will it update the existing path configuration? It is production host. Thats why i would like to reconfirm with you guys.
Thanks in Advance
Shameem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 09:37 PM
02-23-2010 09:37 PM
Re: Cron Job Issue
can we redirect to a log file to capture the output of your script while execution in crontab.
so that we will all know what causing the actual problem. Guess we are all shooting in the dark room.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 09:44 PM
02-23-2010 09:44 PM
Re: Cron Job Issue
I tried with that option...find the log output
#cat /tmp/log.out
Waiting until tar is complete ...
Tar completed successfully
Waiting until gzip is complete ...
Gzip completed successfully
tar & zip is completed with 0 bytes.. if i run manually at same time, some files exists in zip.
Kindly clarify on this
Thanks in Advance
Shameem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 09:55 PM
02-23-2010 09:55 PM
Re: Cron Job Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 10:05 PM
02-23-2010 10:05 PM
Re: Cron Job Issue
>As the user you are running "manually" the script and it is working, do
set
and copy PATH line into your SCRIPT.
Please re-attach the modified script here.
Horia
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 10:05 PM
02-23-2010 10:05 PM
Re: Cron Job Issue
Waiting until tar is complete ...
Tar completed successfully
Waiting until gzip is complete ...
Gzip completed successfully<<<
as long as i see from above. time taken "tar" is too short. and between you can "use " sleep command optins
man sleep
"sleep - suspend execution for an interval"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2010 10:29 PM
02-23-2010 10:29 PM
Re: Cron Job Issue
Would be better to implement logging like this:
(Put in front of this script your declarations)
------------------------------------
LOGF=/tmp/my_script.log
echo "\n\n\nStart Script at `date`" >> $LOGF
echo " Waiting until tar is complete ..."
touch readme $REPO/readme.txt
tar -cvf $REPO/$TAR $REPO/readme.txt >> $LOGF
find $J2EE -type f -mtime -1| xargs tar -rvf $REPO/$TAR >> $LOGF
echo " After first find/tar " >> $LOGF
ll $REPO/$TAR >> $LOGF
find $J2EE -type l -mtime -1| xargs tar -rvf $REPO/$TAR >> $LOGF
echo " Tar completed successfully " >> $LOGF
echo " After the second find/tar " >> $LOGF
ll $REPO/$TAR >> $LOGF
echo " Waiting until gzip is complete ..."
gzip -c -9 $REPO/$TAR > $REPO/$FILE
echo " Gzip completed successfully "
rm $REPO/$TAR
# Once done, SCP to the DR system
su - $USER -c "scp -i $KEY $REPO/$FILE $USER@$DEST:$REPO"
echo "File EPP-J2EE-FS.tar.gz transferred on `date`" >> $LOG
# Delete the created file; else next job will fail
rm -rf $REPO/$FILE
--------------------------------------------
Run the script through cron and paste here the content of the /tmp/my_script.log
Paste also the modified script (including the PATH and the rest of the declarations - remove any values you consider necessary to protect your privacy)
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2010 12:19 AM
02-24-2010 12:19 AM
Re: Cron Job Issue
Thanks for your response.
I found below information during script execution.
tar file creation take 8min & it is created successfully. gz file created with 0 bytes.
Then I put sleep 300 after below command
find $J2EE -type f -mtime -1| xargs tar -rvf $REPO/$TAR
find $J2EE -type l -mtime -1| xargs tar -rvf $REPO/$TAR
again gz file created with 0 bytes.
Again i put sleep after below command
gzip -c -9 $REPO/$TAR > $REPO/$FILE
Still gz file created with 0 bytes. Now problem with gz file only not with tar file.
Hello Horia,
Thanks for your response.
I found problem is in gz file. do you need to get the log information from each line from the script as per your previous update?
For PATH configuration, If I set a path using set command, will it update the existing path configuration? It is production host. Thats why i would like to reconfirm with you guys.
Shameem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2010 12:24 AM
02-24-2010 12:24 AM
Re: Cron Job Issue
You should not use
set
command in your script file (at least not in this file!)
I just said that you should use the set command in order to find out the original environm. for the user that you claimed that the script worked as expected. (like this you would get the PATH value that you would copy into your script file, at the beginning)
Horia.
Horia.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2010 12:50 AM
02-24-2010 12:50 AM
Re: Cron Job Issue
put in your script:
#===========================================
# Load environment
#===========================================
. ~/.profile 1>/dev/null
this will assure you to have the same environment in crontab as you execute teh script manually.
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2010 02:51 AM
02-28-2010 02:51 AM
Re: Cron Job Issue
Issue is resolved. Issue with PATH details.
Configured /usr/contrib/bin/gzip instead of gzip.
As per your opinion, If I configure PATH information in the script also resolve this issue.
Thanks
Shameem