... ... ...
I get that my problem probably has to do with setting the environment variables, but it's not clear to me yet how to do that.
"When you run the program manually and it works, what shell are you using? Change the 1st line of your script from:
to:
where pathname is the absolute pathname of the shell you are using. Does that change make your script work when run by cron ?"
Since the first line in the script is shell=bin/bash, I'm using the bash shell, right?
Yes, No, Maybe!
If the default shell for your system is /bin/bash, then having the line:
in your script does nothing and your script is being run by bash. If the default shell for your system is NOT /bin/bash, then having the line:
in your script does nothing and your script is NOT being run by bash; it is being run by the default shell on your system.
If you type the command:
into your shell, does the shell you are using magically change to /dev/null? NO. All it does is set a shell variable that later lines in your script (or, when done interactively, in your login session) can access by testing the value of $shell.
By convention (when your login shell is not a csh derivative), when you login the shell variable SHELL is exported and set by the system to an absolute pathname of your login shell. My login shell is /bin/ksh and after I login, $SHELL expands to /bin/ksh. If I then invoke bash, $SHELL still expands to /bin/ksh. Note also that case matters: $SHELL and $shell are two different variables.
If the script you are asking cron to run is an executable file and the 1st two characters in that file are #!, the system will use the interpreter named by the pathname on the rest of that line as the program used to interpret the rest of that file.
Now, back to your environment problem...
If you don't know what environment variables /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export needs to have set in order for it to work correctly, you need to set all of the variables in your script to the same values that they have when you run /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export manually and it works.
When you login with bash as your login shell, it runs three files from your home directory if they are present: .bash_profile, .bash_login, and .profile. If those files are where the variables /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export needs to run are defined, the following might work for you. Change:
in your script to:
One would expect that one or more of those three files initializes PATH (although it appears that your script doesn't depend on any utilities that are not on the default PATH that you aren't referencing with absolute pathnames) and other shell variables to the values you'll need to run /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export, but we can't know that for sure since we have no idea what other commands you have run after you last logged in to your system before you successfully run /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export from your interactive shell. And, as we have repeatedly said, without knowing what /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export is doing, we are just guessing. If /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export tries to open your controlling terminal for some reason, it might just not be possible to run /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export from cron at all.
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)