LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to run this cron job (https://www.linuxquestions.org/questions/linux-general-1/how-to-run-this-cron-job-184216/)

ashley75 05-21-2004 03:02 PM

how to run this cron job
 
Hi all,

I have the below cron job and it ran as follow:

[sde@test MYDATA]$ ./compress_test.sh


ArcSDE 8.3 Build 284 Thu Jul 17 14:55:03 PDT 2003
Version Administration Utility
-----------------------------------------------------
Compress state tree: Are you sure? (Y/N):


the question is "how can you implement the Y in the option above so your job can run as schedule time???"

thank

lyle_s 05-21-2004 03:19 PM

You should be able to use the "yes" command for this:

yes | ./compress_test.sh

If your script won't accept a lowercase y:

yes Y | ./compress_test.sh

Keep in mind that the yes command will keep on feeding "y"s to your program if it does
any more reads.

Lyle

ashley75 05-21-2004 03:42 PM

thanks for your input.

this is what I would like to do:

schedule this script into the cronjob so it can run every night

1. how can you build what you suggest along with the cron job I have in the cron tab???

2. one more favor from you, how can you trace the statistics of the job into the log file so that we will know if the job running succesfully or not????

thanks so much

lyle_s 05-21-2004 05:19 PM

Run the command:

crontab -e

as the user you want the script to run as. This opens up your crontab in vi; hopefully you have the vi basics down.

You want the following to appear in your crontab:

0 1 * * * cd /path/to/MYDATA && yes | /path/to/compress_test.sh &> /path/to/"$(date --iso).compress.log"

(It should be all be on one line.)

Adjust the "/paths/to"s accordingly; they don't necessarily have to be the same. This will run it at 1:00 a.m. every night; see man crontab to adjust this. The log files will contain whatever your program outputs. The log files are prepended by the date so it won't overwrite previous nights runs and so they sort by increasing date when listed.

Lyle

ashley75 05-24-2004 10:38 AM

ok so confused and my cron job doesn't work.

below is what I have in my cronjob save as compress_test.sh


ORACLE_SID=mytest
export ORACLE_SID
SDEHOME=/home/sde/sdeexe83
export SDEHOME
$SDEHOME/bin/sdeversion -o compress -i esri_sde -u sde -p sde



--save this script and compress_test.sh
--change the permission so the user can execute
--I did run the script manually and it ran successfully



so now I ready to put this scripts into the cron job as follow:

10 10 * * * cd /home/sde/stuffs/scripts/mytest/ && yes | /home/sde/stuffs/scripts/mytest/compress_test.sh


and I got the below error on the mail



X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/sde>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=sde>

/home/sde/sdeexe83/bin/sdeversion: error while loading shared libraries: libsde83.so: cannot open shared object file: No such file or directory

lyle_s 05-24-2004 11:20 AM

My first guess is the LD_LIBRARY_PATH environment variable isn't in the environment set up by cron to run your script.

What to do:
  1. Determine what LD_LIBRARY_PATH is set to when logged in as a user that can successfully run the script:
    echo $LD_LIBRARY_PATH.
  2. Add a line in compress_test.sh that sets LD_LIBRARY_PATH to that value (similar to the lines you already have that set environment variables.)

The LD_LIBRARY_PATH environment variable adds places to search for shared objects (also known as dynamically linked libraries).

Lyle


All times are GMT -5. The time now is 01:31 PM.