Cron Issue

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Cron Issue
# 1  
Old 08-10-2010
Cron Issue

Hey all! I'm working on setting up a script to run with cron. I have thus far been unable to get it to successfully complete. I'm hoping you gurus can lend me a hand.

This is my crontab, the transfer script works fine the backup will not. The backup however does work when I execute it from the command line.

Code:
SHELL=/bin/bash
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/data1/baminstall:/home/Admin/bin
HOME=/home/Admin

*/2 * * * *  /opt/data1/BAM/utils/backup.sh
*/13 * * * * /opt/data1/BAM/utils/transfer.sh

The Cron logs show that it is executing it without errors...
Code:
Aug  9 16:52:01 BAM_PNPT crond[13936]: (root) CMD (/opt/data1/BAM/utils/backup.sh)
Aug  9 16:54:01 BAM_PNPT crond[13980]: (root) CMD (/opt/data1/BAM/utils/backup.sh)
Aug  9 16:56:01 BAM_PNPT crond[14018]: (root) CMD (/opt/data1/BAM/utils/backup.sh)
Aug  9 16:58:01 BAM_PNPT crond[14064]: (root) CMD (/opt/data1/BAM/utils/backup.sh)

This is the script I am trying to run.
Code:
#!/bin/bash
#!/usr/bin/
set PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/data1/baminstall:/home/Admin/bin

java -classpath "MicroXML.jar:log4j.jar:fileIO.jar:logging-server.jar:br-server.jar:core-server.jar:ds-server.jar:postgresql-8.1-404.jdbc2ee.jar" \
org.mg.br.server.utils.BackupRestoreCli -action backup -xml BackupRestoreConfig.xml

Thank you in advance!

---------- Post updated at 10:54 AM ---------- Previous update was at 10:49 AM ----------

Code:
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
USER=root
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
KDEDIR=/usr
MAIL=/var/spool/mail/root
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/data1/baminstall:/root/bin
INPUTRC=/etc/inputrc
PWD=/root
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/root
LOGNAME=root
LESSOPEN=|/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env

These are my env variables..
# 2  
Old 08-10-2010
In your script, there are a few issues that I see off the top of my head.

First, the second shebang (#!) will not be parsed and it serves no purpose that I can see.

Secondly, if you are executing this as a bash script, you should not use "set" you should use export.

Also, you may want to change your PATH but unless you are certain everything that you need will be called from your path, you may want, as a practice to do as follows:

Code:
export PATH=<your paths>:$PATH

# 3  
Old 08-10-2010
Thanks for the reply! I've changed the script to this. Still no luck. Any other ideas?

Code:
#!/bin/bash

java -classpath "MicroXML.jar:log4j.jar:fileIO.jar:logging-server.jar:br-server.jar:core-server.jar:ds-server.jar:postgresql-8.1-404.jdbc2ee.jar" \
org.mg.br.server.utils.BackupRestoreCli -action backup -xml BackupRestoreConfig.xml

# 4  
Old 08-10-2010
You forgot to export your path as suggested above. cron gets a much more minimal path than a shell login, so it won't be able to find certain programs until you set a better PATH yourself.
# 5  
Old 08-10-2010
I tried it that way as well without success. I'm at a loss to why it isn't working..
# 6  
Old 08-10-2010
The way you run your cronjob (without > /dev/null 2>&1) suggests that the actual output from your cronjob should be in your user's mailbox.

Check your mail on the server.

(as an aside, I don't think */13 notation transcends boundaries, so it will run at 0, 13, 26, 39, 42, 55, 0, 13, ..., etc, minutes past the hour, but I may be wrong Smilie)
# 7  
Old 08-10-2010
I've done the mail command and it tells me no mail on server Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron issue

i have written a script to sftp yesterday's logs from another server as below: cd /export/home/abc/xyz/tt d=`gdate -d'yesterday' +%Y%m%d` sftp abc@XXX.XX.XX.XX<<EOF cd /yyy/logs/archive mget abc.log.$d* EOF cd /export/home/abc/xyz/scripts nohup ./ss.sh PROD & it is working fine... (2 Replies)
Discussion started by: ssk250
2 Replies

2. Solaris

CRON Issue

Hello, I am running Solaris 8. I have set a cron job that runs every couple hours. If I run the script manually, it runs just fine (logged in as root). The cron however will not run. It is producing an rc=1 error. Any thoughts would be appreciated. Thanks (4 Replies)
Discussion started by: jkmtm
4 Replies

3. Ubuntu

Cron Issue

I have written a custom cron. This cron executes a rake task every 5 minutes. I also log the trace of this execution in a file locally on my server. The whole process seems to execute seamlessly every 5 minutes, but then it seems to log it in /var/log/syslog. I investigated on the syslog and found... (3 Replies)
Discussion started by: manjunath.nm89
3 Replies

4. UNIX for Dummies Questions & Answers

Cron Issue

I have written a custom cron. This cron executes a rake task every 5 minutes. I also log the trace of this execution in a file locally on my server. The whole process seems to execute seamlessly every 5 minutes, but then it seems to log it in /var/log/syslog. I investigated on the syslog and found... (0 Replies)
Discussion started by: manjunath.nm89
0 Replies

5. UNIX for Advanced & Expert Users

Cron Issue

I have written a custom cron. This cron executes a rake task every 5 minutes. I also log the trace of this execution in a file locally on my server. The whole process seems to execute seamlessly every 5 minutes, but then it seems to log it in /var/log/syslog. I investigated on the syslog and found... (0 Replies)
Discussion started by: manjunath.nm89
0 Replies

6. Shell Programming and Scripting

Issue with Cron

Hi Gurus, I need to run a script every saturday at 7:05 PM. Below command is working in x86_64. 05 19 * * 6 /apps/informatica/scripts/inf_rest.ksh However when I tried in HP-UX it is giving the below error. crontab: error on previous line; unexpected character found in line. Please... (4 Replies)
Discussion started by: svajhala
4 Replies

7. Shell Programming and Scripting

A Cron Issue

Hi Guys.,, This thing is driving me crazy.. I have this script which runs perfectly fine. If it is not able to connect to database it will drop a mail which it does when i ran it manually. But when i am running it from crontab, the script is not sending mail to me but to my id(login id)... (0 Replies)
Discussion started by: mac4rfree
0 Replies

8. Red Hat

cron issue

Hello, Having and issue with a job scheduled in cron. The script: #!/bin/bash 2 3 # Example shell script which can be added to roots cron job to check the 4 # Embedded Satellite disk space usage. If any table is over 90% usage, send 5 # a notice to the default email address... (2 Replies)
Discussion started by: mgb
2 Replies

9. Solaris

Cron issue

When I list whats in cron -l its fine but when I try to -e edit it...it returns a number 309 can't you not edit cron this way with solaris 10? I can do it fine in sol 8 and 9. export EDITOR="vi" is set in my profile I am using BASH $ sudo crontab -l Password: #ident "@(#)root ... (5 Replies)
Discussion started by: kingdbag
5 Replies

10. UNIX for Advanced & Expert Users

cron issue

user x has a cron job that looks in a dir and moves teh files from 1 name to another except its not working correctly. . /user/.profile # sorce the users profile for file in `ls`; do mv $file $file.`date +%Y%m%d%H%M%S``microsec` done microsec is a binary with 555 perm. on it in... (5 Replies)
Discussion started by: Optimus_P
5 Replies
Login or Register to Ask a Question