Sponsored Content
Top Forums Shell Programming and Scripting Problems with a crontab shell Post 302992409 by Manolo on Friday 24th of February 2017 01:07:47 PM
Old 02-24-2017
Problems with a crontab shell

Hi everyone, can you help me ?, I have the following shell:

Code:
DIR="/backups/backdata"
DIR_2="/BACKOPENF/database"
LOG="/backups/logs/oracle_backup.log"
EXP_LOG="/backups/logs/Exp`date +%Y%m%d%H%M%S`.log"
EXP_FILE="Exp`date +%Y%m%d%H%M%S`.dmp"
HOLD_DAY=1

# String de conexion
oracle_username="system"
oracle_password="password"

# Se define una  funcion ECHO para que siempre ponga fecha
ECHO () {
printf "%s " `date '+%Y-%m-%d %H:%M:%S'`
echo $1
}

ECHO "Inicio"
# Se borran los mas viejos que $HOLD_DAY dias.
ECHO "Borrado de archivos viejos"

OLD_FILE=`find $DIR -mtime +$HOLD_DAY -name Exp20\*.Z`
if [ -n "$OLD_FILE" ]
then
        ECHO "El sigiuete archivo es mas viejo que $HOLD_DAY dia y sera borrado.
"
        ECHO $OLD_FILE
        find $DIR -mtime +$HOLD_DAY -name Exp20\*.Z -exec rm {} \;
fi

        mknod "$DIR/$EXP_FILE" p
        compress < "$DIR/$EXP_FILE" >  "$DIR/$EXP_FILE".Z &
       sleep 5
        ECHO "Inicio de backup"
        /oracle/app/oracle8/product/8.1.7/bin/exp $oracle_username/$oracle_passw
ord@openflex owner=FLEX, EPAYMENT, IMS, EXPERT, ADMIN,  FILE="$DIR/$EXP_FILE" LO
G=$EXP_LOG;
        ECHO "Fin de backup"
       sleep 5
       ECHO "Borrado de archivo temporal y copiado del nuevo"
       rm "$DIR/$EXP_FILE"
       cp "$DIR/$EXP_FILE".Z "$DIR_2"

echo "-----------------EOF-----------------"
# End.





And its execution (crontab) results in the following log file:

Code:
2017-02-23 01:00:00 Inicio
2017-02-23 01:00:00 Borrado de archivos viejos
2017-02-23 01:00:05 Inicio de backup
2017-02-23 01:00:05 Fin de backup
2017-02-23 01:00:10 Borrado de archivo temporal y copiado del nuevo

It does all the command except the export line ... Running in console it works fine

Thank you...



Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 02-24-2017 at 02:40 PM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

no shell invoked in crontab

Hi all, I am trying to run a script in crontab but I receive the email below. Note the empty variable SHELL. Apparently cron doesn't invoke a shell. That explains the errors in the script it is trying to execute. Anyone know what maybe wrong? Subject: Output from cron job... (3 Replies)
Discussion started by: ivanushka
3 Replies

2. UNIX for Dummies Questions & Answers

Crontab and shell pb

Hi, i try to execute the following in a crontab file and it doesn't work while the same line is OK on the Unix (AIX) shell command line. 42 15 * * 1 > /users/notes01/tata.${date +"%d%m%Y"} it seems to be a pb related to date flags expression but i can't see why , somebody have an idea ? ... (4 Replies)
Discussion started by: Nicol
4 Replies

3. Shell Programming and Scripting

How do i run a shell script without crontab.

Hi Folks, Could you please suggest me how to run a shell script on a solaris env without using crontab. I am actually trying to write a shell script which will grep "WORD" in the logfile andd sends a email.Thanks in advance. Thanks Sandeep. (3 Replies)
Discussion started by: sandeep anand
3 Replies

4. UNIX for Dummies Questions & Answers

Execution problems with crontab

I need your help please Inin a production system i found crontab entries was removed because i typed crontab -l with username corasc and didn't show anything. i asked the administrador to restored the mentioned crontab, he restored the crontab: The problem is when restored the crontab file is... (2 Replies)
Discussion started by: alexcol
2 Replies

5. Red Hat

Problems with script running with crontab

Hi, I'm trying the backup a few information commands of my Check Point FW (it's on a SPLAT linux machine). This is the script I wrote: #!/bin/bash cd /var/tmp/ file1=netstat_`/bin/date +%d%m%y`.txt file2=ifconfig_`/bin/date +%d%m%y`.txt file3=cpstatos_`/bin/date +%d%m%y`.txt... (2 Replies)
Discussion started by: nirsh
2 Replies

6. Debian

Problems with Crontab not executing scripts after edit

Hi all I installed Debian and i have a few scripts that outputs what is happening. The wierd part...after fresh install all works ok but after i open or edit Crontab it stops executing the scripts...and scripts runs manually so its not a problem with scripts...what happens is that i usually... (3 Replies)
Discussion started by: ro0t3d
3 Replies

7. Shell Programming and Scripting

Change crontab from shell script

Hi All, I have scheduled a script to run every five minutes through crontab. If there is any issue with the script which may need manual intervention, I have used the mailx commands. But at the same time, I would want the cron to be disabled until the issue is resolved. Once things are fine,... (2 Replies)
Discussion started by: adi_2_chaos
2 Replies

8. Shell Programming and Scripting

use crontab for a shell script..

hi, i have shell script which checks for service running on platform, if service is receiving calls, then do nothing if service is not receiving calls, then stop the service i want to run this script in 2 timeslots. i.e. in the day from 9 am to 5 pm it should run every 10 minutes and ... (2 Replies)
Discussion started by: gauravah
2 Replies

9. Shell Programming and Scripting

Wants to change shell script into crontab

Hi friends, Actually i wrote many scripts in korn shell for time saving activity in storage domain. But every week i am spending some time for the running of script. So every Monday i wants to run my scripts automatically. So corn will be helpful according to my friend's opinion. But I don't... (5 Replies)
Discussion started by: Mahendranath
5 Replies

10. UNIX for Dummies Questions & Answers

Execution Problems with Crontab

Dear Folks, I have written a shell script which internally connects to oracle database through sqplplus command line. The script runs fine when run manually. Now I am scheduling it to run (Linux environment) from crontab. In crontab it is failing with an error: sqlplus command... (6 Replies)
Discussion started by: tamojitc
6 Replies
All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy