Sponsored Content
Operating Systems Linux Red Hat Linux ksh script not working in crontab Post 302962635 by mrn6430 on Wednesday 16th of December 2015 08:11:38 PM
Old 12-16-2015
Linux ksh script not working in crontab

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 !

Code:
#!/usr/bin/ksh

host=`uname -n`
tdate=`date`
userid='dbid/password'

totalevents=`sqlplus -s $userid << -
  set timing off
  set head off
  select count(1) from async_data_transfer where interface_id='9';

-
`
totalevents=$(echo $totalevents | tr -d '\n ')

EmailList=hello@yahoo.com\

"
echo "$totalevents"
echo "Estimated queue accumulated per SSG in Reston  =  $totalevents events. " | mailx -s "$host Reston SSG Queue Counts" $EmailList
exit 0


Here is my crontab looks like:

Code:
0,15,30,45 * * * * /home/cpac/scripts/CommandLine/chkssgQueue.ksh > /dev/null

---------- Post updated at 07:11 PM ---------- Previous update was at 06:25 PM ----------

Just figured it out. I just needed to add this line to my script:
Code:
. ${HOME}/.profile

crontab just does not have a way to know where my sqlplus is located. It worked when I added that line and it worked.

Last edited by rbatte1; 12-18-2015 at 09:59 AM.. Reason: Added CODE tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script is not working when put in crontab

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)
Discussion started by: *Jess*
2 Replies

2. Shell Programming and Scripting

run script through crontab using ksh

hi i have a script called test.sh. the content is ls >> crontest.txt. if i run manually it's giving output.but if i scheduled in crontab it's not giving output. crontab entry: 02 * * * * /sms5/SMSHOME/eds_sh/test.sh >> /sms5/SMSHOME/eds_sh/testfile/logfile 2>&1 I am using ksh.is there... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

3. Shell Programming and Scripting

Expect Script Not working with Crontab

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)
Discussion started by: alagondar
2 Replies

4. Shell Programming and Scripting

My script stops working when using crontab

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)
Discussion started by: splinter_cell
6 Replies

5. Shell Programming and Scripting

Script not working in crontab

Hi I have created a script. Which i have configured in cron to make it run in every 2 min. But script is not running. If I checl the cron log at /var/cron/log .it shows its running in every 2 min. Below is the command which i configured in crontab. But I am not able to find the way so that... (9 Replies)
Discussion started by: nandan8a
9 Replies

6. Shell Programming and Scripting

[Solved] Shell script not working in crontab

Hi Iam running below script in crontab but its not working. #!/bin/sh cd /Scripts /usr/local/bin/expect -f /Scripts/bng_backup.exp /Scripts/data.txt tar -cf bngbackup.tar bngbackup ;gzip bngbackup.tar when iam running manually the output file is generating..but bngbackup.tar.gz file... (5 Replies)
Discussion started by: surender reddy
5 Replies

7. UNIX for Dummies Questions & Answers

Script is not longer working in the crontab

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)
Discussion started by: alexcol
6 Replies

8. Red Hat

Script not working if crontab scheduled

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)
Discussion started by: idro
5 Replies

9. Shell Programming and Scripting

Script not working via crontab

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)
Discussion started by: ash12345
6 Replies

10. Shell Programming and Scripting

Script not working via crontab

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)
Discussion started by: ash1234
1 Replies
MUPDATETEST(1)						      General Commands Manual						    MUPDATETEST(1)

 *

NAME
mupdatetest - interactive MUPDATE test program SYNOPSIS
mupdatetest [ -p port ] [ -m mechanism ] [ -a userid ] [ -u userid ] [ -k num ] [ -l num ] [ -r realm ] [ -f file ] [ -n num ] [ -q ] [ -c ] [ -i ] [ -o option=value ] [ -v ] hostname DESCRIPTION
mupdatetest is a utility that allows you to authenticate to a MUPDATE server and interactively issue commands to it. Once authenticated you may issue any MUPDATE command by simply typing it in. It is capable of multiple SASL authentication mechanisms and handles encryption lay- ers transparently. This utility is often used for testing the operation of a mupdate server. Note that you must be an admin in order to authenticate to an mupdate server. OPTIONS
-p port Port to connect to. If left off this defaults to mupdate as defined in /etc/services. -m mechanism Force mupdatetest to use mechanism for authentication. If not specified the strongest authentication mechanism supported by the server is chosen. -a userid Userid to use for authentication; defaults to the current user. This is the userid whose password or credentials will be presented to the server for verification. -u userid Userid to use for authorization; defaults to the current user. This is the userid whose identity will be assumed after authentica- tion. NOTE: This is only used with SASL mechanisms that allow proxying (e.g. PLAIN, DIGEST-MD5). -k num Minimum protection layer required. -l num Maximum protection layer to use (0=none; 1=integrity; etc). For example if you are using the KERBEROS_V4 authentication mechanism specifying 0 will force mupdatetest to not use any layer and specifying 1 will force it to use the integrity layer. By default the maximum supported protection layer will be used. -r realm Specify the realm to use. Certain authentication mechanisms (e.g. DIGEST-MD5) may require one to specify the realm. -f file Pipe file into connection after authentication. -n num Number of authentication attempts; default = 1. The client will attempt to fast reauth (e.g. DIGEST-MD5), if possible. -q Enable MUPDATE COMPRESSion (before the last authentication attempt). -c Enable challenge prompt callbacks. This will cause the OTP mechanism to ask for the the one-time password instead of the secret pass-phrase (library generates the correct response). -i Don't send an initial client response for SASL mechanisms, even if the protocol supports it. -o option=value Set the SASL option to value. -v Verbose. Print out more information than usual. SEE ALSO
mupdate(8) CMU
Project Cyrus MUPDATETEST(1)
All times are GMT -4. The time now is 04:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy