Job runs manually, doesn't work in crontab


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Job runs manually, doesn't work in crontab
# 1  
Old 06-13-2016
Job runs manually, doesn't work in crontab

I have a script (/home/admin/run_bkup.sh) that I can run manually to kick off an executable job. I want to run it in crontab, but it doesn't work.

Here's the script:

Code:
shell=/bin/bash
today=$(date +"%m-%d-%y")
/opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export mgt-svr-bkup-$today << EOF
y
n
EOF

It would be easier to just add the executable job to crontab, but the executable job is interactive, requiring a response to two questions.

Here is the crontab entry:

Code:
00  6  *  *  1   /home/admin/run_bkup.sh

What do I need to do to get this job to run in crontab?
# 2  
Old 06-13-2016
Try specifying full paths for all the commands in the script.
# 3  
Old 06-13-2016
/opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export is the full path.
# 4  
Old 06-13-2016
Source the user environment before executing in cron.
Check the $HOME directory for environment files and/or env command.

Also the syntax defines shell variable as /bin/bash for some usage.
I do not see it being used further in the program, but one can only the guess what is upgrade_export, perhaps it is used in it.

You would want to define a magic cookie in your script !#/bin/bash as the first line.

Further on, i believe that export can be done from managment of checkpoint fw or ? Smilie
You might want to notice the post under this thread, since people are having these types of issues all the time.
# 5  
Old 06-13-2016
date is not full path. If you told us WHAT "doesn't work" you might get a more meaningful answer - if the references at the bottom of this page don't suffice.
# 6  
Old 06-13-2016
mgt-svr-bkup-$today is not an absolute pathname either. There is no reason to believe that your cron job is going to run in the directory in which you invoked the crontab utility to add your cron job to the schedule.
# 7  
Old 06-13-2016
Quote:
Further on, i believe that export can be done from managment of checkpoint fw or ?
- Thx, Peasant, but I don't know what this means.
Quote:
If you told us WHAT "doesn't work" you might get a more meaningful answer
- RudiC, thanks for the response. There is no output that I can see.

Quote:
Code:
mgt-svr-bkup-$today

is not an absolute pathname either.
- Don, thx for the response. I didn't think
Code:
mgt-svr-bkup-$today

was a file that required an absolute path. The output file from the executable job is
Code:
mgt-svr-bkup-$today.tgz

. I assumed
Code:
mgt-svr-bkup-$today

was a parameter passed to the job to be used when creating the output file. If I'm wrong, and it is the file (without the .tgz extension), then this should work? -

Code:
shell=/bin/bash
today=$(date +"%m-%d-%y")
/opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export /opt/CPsuite-R77/fw1/bin/upgrade_tools/mgt-svr-bkup-$today << EOF
y
n
EOF

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script runs manually, but not from cron

Hi, I "borrowed" a script I found online, to start a SAP router application on a Solaris 11 (SPARC) server. The script runs fine when calling it manually, but when I schedule it to run from cron, it doesn't. I don't see any warning or failure messages anywhere, just nothing happens. ... (11 Replies)
Discussion started by: bredman
11 Replies

2. UNIX for Dummies Questions & Answers

Script runs manually but not from crontab in UNIX

Hi Guys, I am executing the script called Delet.sh manually it is successfully completing the task but it is failing to run vi cron tab, I tried to pass PATH & .profile before execution but no luck, Any suggestions? Script below #!/usr/bin/ksh #set -x # Purpose : Delete folders file from... (9 Replies)
Discussion started by: Anilsa77
9 Replies

3. Shell Programming and Scripting

Script runs good manually but failing via crontab

Hello Gurus, I have written small script which will start the given service if its stop .Its running fine when manually executed but its unable to run from crontab. #!/bin/bash SERVICENAME=rsyslog service $SERVICENAME status > /dev/null SYSLOGSTATUS=`echo $?` COUNT=0 THRESHOLD=3 if ... (4 Replies)
Discussion started by: kapil514
4 Replies

4. Shell Programming and Scripting

Part of the Shell script is not running via crontab, runs fine manually

Hello Team, As a part of my job we have made a script to automate a service to restart frequently. Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Discussion started by: gowthamakanthan
18 Replies

5. Shell Programming and Scripting

Script runs fine manually but not in crontab

Hello Guys, I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following. 1) When I manually execute following script it runs successfully with below output. bash-3.00# more smssend #!/bin/bash echo -e "<Request... (16 Replies)
Discussion started by: umarsatti
16 Replies

6. Shell Programming and Scripting

cronjob not running but runs manually

hello, i recently switched to a new ec2 box and transferred the cronjobs from the old box. For some reason one of the scripts won't work but it runs manually from the command line. I've read from previous threads it might be an environment issue but I added a line with the path to the script... (2 Replies)
Discussion started by: lencholamas
2 Replies

7. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hello all, I'm new here and have a question if you don't mind helping me. I have a script that will work if I kick if off manually but not from Cron. My cron entry is this: 05,20,35,50 * * * * /scripts/status.sh > /dev/null 2>&1 The first script (works fine) is this: #!/bin/sh # #... (14 Replies)
Discussion started by: hs3082
14 Replies

8. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hi all I have this inside a shell script (bash): cd DIRECTORY find . -maxdepth 1 | sed 's#./##' | /usr/bin/xargs -I '{}' chown -Rv '{}' /DIRECTORY/'{}' All the directories in this location are named after usernames, so it simply sets the owner to that of the username of the folder. It... (5 Replies)
Discussion started by: fakesy
5 Replies

9. Shell Programming and Scripting

IDL job doesn't work from crontab

I have made a script to execute an IDL routine with the purpose to plot data on a fixed time. The problem is that when I include this script in the crontab to run it every night, the IDL part doesn't work (the other commands, like getting data from the database, are carried out though). This... (4 Replies)
Discussion started by: SharkM
4 Replies

10. Shell Programming and Scripting

Expect script doesn't work under crontab

Hi All, Using Expect script when I run it manually it works. But when I put the entry in crontab, the job is still running after 15 hours. The script was created as root. I don't think it's a permission issue. Any idea? This is what I have under root crontab... 00 18 * * 1-5... (4 Replies)
Discussion started by: samnyc
4 Replies
Login or Register to Ask a Question