Please post precisely what Operating System and Shell on this and every subsequent thread. Please also post the output from set when you are running in a normal terminal session so we can work out what /bin/sh means when you are running from cron:
There are many areas of your script which need attention:
1) Corona688 has already pointed out that the backticks are neither required nor advisible in this context.
2) The Environment Variable $ESAHOMEINSTALL is not set anywhere in the script. Please post the output from the set command when logged in interactively so we can see your interactive environment (which will be quite radically different from the environment when running from cron).
3) The script includes dodgy numeric comparisons:
In all of these cases, lose the double quotes. You are comparing numbers not strings.
4) Is it safe to assume that the weird output in /tmp/sigcheck.log did not come from the script as posted but only happens if you include . /etc/profile in the script? Executing . /etc/profile in this context is inadvisible because there is no terminal context.
If true, please post the actual output seen in /tmp/sigcheck.log which matces the script posted.
5) The whole script design depends on processing ps -ef every two-minutes. This is madness. Eventually you will hit a moment when the kernel is busy and ps -ef returns a null or incomplete response.
Ideally you would record the PID of the process in a file when it starts. Then you only need to query the one PID. ps -fp<pid>.
At a minimum consider confining to ps -fu<username> where username is the name of the user who owns the crontab.
Within your script, consider code to only react to say three consecutive failures rather than just the one.
Last edited by methyl; 08-08-2012 at 09:20 PM..
Reason: layout;typos
Hi there, this is part of my script:
/usr/bin/cd /u01/oradata
/usr/bin/cp `/bin/ls -1 . |grep -v "^DIMStemp01.dbf$" | grep -v "^DIMSts01.dbf$"|grep -v "^DIMStects01.dbf$"` /backup
It's working fine when I manually run on telnet session.
/bin/ls -1 . -- to list all the files inside... (2 Replies)
Hi,
This script is working successfully when i executed from shell prompt, but the same script scheduled in crontab its not deleting the files,
#! /bin/bash
DAY_1=`(date --date='4 months ago' '+%Y-%m')`
log=/tmp/cleant
adir=/u01/app/oracle/admin/talon/adump... (4 Replies)
I have the following expect script sitting on a Linux box.
===
#!/usr/bin/expect -f
#
# backup.expect
#
# Expect script to backup a firewall via a SSH session
#
#
set firewall
set username
set password
set prompt
set filename
match_max 50000
spawn ssh -l... (2 Replies)
I have made a shell script(/bin/sh) that starts a perl script (that I haven't made my self) that's starts a ssh session. The ssh session uses a private/public key to login so no password is needed. The Perl script works perfect.
But when I put it in a cronjob (crontab) the ssh connection asks... (6 Replies)
This is the crontab it is supossed to be running everyday but it didnt
5 0 * * * /export/app/CO/opge/scr/Informe_parametros_colombia.ksh >/dev/null 2>&1
Inside the above script connects to a database and extract data to a flat file, manually i run the script at about 2 a.m. and Works OK,... (6 Replies)
Hi All,
I am testing expect script in command prompt without issue, but in crontab it is not working, i check the output error as below:
#cat /var/log/testexp.log
spawn minicom -C /var/log/minicom1.log
No cursor motion capability (cm)
AT+COPS=?
I am new in scripting, together... (1 Reply)
Hi all,
I'm working to a script with /bin/bash shebang.
The script works perfectly if I run from command line.
The script runs under a non root user and inside the commands are set with sudo command in a such a way they can be run under root, for example (first rows of the script):... (5 Replies)
Hi,
I have written one script which is connecting to the the database and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is generating and working fine but same script when i have configured in crontab not working and giving error, kindly... (6 Replies)
Hi,
I have written one script which is connecting to the the database and generating one CSV, it is running fine when i ran it manually though it is throwing any warning but CSV is generating and working fine but same script when i have configured in crontab not working and giving error, kindly... (1 Reply)
I am Not sure why following script is not capturing the counts only when using crontab !! when I run it fromt he command line it is fine ! what is missing here !
#!/usr/bin/ksh
host=`uname -n`
tdate=`date`
userid='dbid/password'
totalevents=`sqlplus -s $userid << -
set timing off
... (1 Reply)