Sponsored Content
Top Forums Shell Programming and Scripting Date command does not work in a KSH when called from Cron Post 302312047 by devilsadvocate on Thursday 30th of April 2009 08:50:11 AM
Old 04-30-2009
Question Date command does not work in a KSH when called from Cron

Hi,

I'm trying to execute a job on the last day of every month, for which i'm using the following code in my Korn shell script :

if [[ `date +%d -d tomorrow` != 01 ]];
then
echo allowed only on last day of month. Today is `date +%d` >t.stm
echo Tomorrow is `date +%d -d tomorrow` >s.stm
exit 0
fi
...
....
.... (actual code to be executed)


Here is the crontab entry for it :

2,32 6-10 28-31 * * /intl_cim/acq_mdl1/cms/prod/global/scripts/trigger.ksh prod > /dev/null 2>&1

Strange enough, when i execute this script from the command prompt it works fine, but when it is executed by the cron, the file s.stm and t.stm show the same date. Which means it is not calculating Date -d tomorrow.

Can you please help me understand why this would happen. Here is what uname -a on my machine says :

SunOS sppmd541 5.10 IDR_139180-01 sun4u sparc SUNW,Sun-Fire-15000

Thanks a lot.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

gzip in shell script called by cron

I'm puzzled by this one. I hope you can explain it to me. I have a ksh shell script that gzips a file among other things. This works perfectly fine when the script is manually run through a shell. However, when the same script is run through cron, it does everything correctly, but it will... (2 Replies)
Discussion started by: hbau419
2 Replies

2. Shell Programming and Scripting

How to determine the script is called from CRON?

Hello expert, What I want is to determine whether the script is called from CRON or it is executed interactively? I tried the following but no luck: #!/bin/ksh cronID=`pgrep -x cron` GPID=`ps -ef -o ppid,pid | grep " $PPID$" | awk '{print $1}'` if ; then echo I am being run... (15 Replies)
Discussion started by: wes_brooks
15 Replies

3. Shell Programming and Scripting

Command doesn't work under cron ?

I have defined in cron crontab -l >/FIXENGINE/data/crontab.$(whoami).$(date +%a) The resulting file is named crontab.fixadmin. When I run the above from a command line, the file is named: crontab.fixadmin.Tue (or whatever day I happen to be running) The question is - why do I get... (4 Replies)
Discussion started by: bigjohn-nj
4 Replies

4. Shell Programming and Scripting

Need help with ksh script that uses sqlplus, called from PHP

I have a ksh script that connects to sqlplus and dumps the query results into a file. The script works file when I run it from the command line, however, when I call it from PHP using system(), exec(), or shell_exec() commands, the script doesn't seem to run the query. It will create the text file... (7 Replies)
Discussion started by: j2owilson
7 Replies

5. Shell Programming and Scripting

want to get previous date from date command in ksh

I want to get previous date from date command. I am using ksh shell. Exmp: today is 2008.09.04 I want the result : 2008.09.03 Please help. Thanks in advance. (4 Replies)
Discussion started by: rinku
4 Replies

6. Shell Programming and Scripting

Script not working when called by cron

Hello, I have the following script which works fine when ran from the command line: #!/apps/python/2.3.4/bin/python import os import sys import time user = os.getenv("USER") string = time.strftime("%m%d%y0000 " + user, time.gmtime()) However, when I have this run by crontab, I... (4 Replies)
Discussion started by: cooldude
4 Replies

7. Linux

Why service (start|stop) can not be called from cron?

Hi, When I googled, I came to know that I can not call the command "service <service-name> start" from cron, insted I have to specify path to the service-name. I wanted to know the reason. Thanks, Hansini (3 Replies)
Discussion started by: hansini
3 Replies

8. UNIX for Dummies Questions & Answers

Interpreting Shell Script errors when called from CRON

Hi All, I am calling a series of shell scripts via CRON so everything is running as root. However, in my error log file I am seeing the following errors. Please can anyone offer any advise as to the possible causes and solution to prevent the errors from appearing. The Error 1227 seems to... (2 Replies)
Discussion started by: daveu7
2 Replies

9. Shell Programming and Scripting

Cron Job - date command problem

Hi I have one problem with cron job in Control Panel. I have a log file that is created once a day on another server and I need to transfer it in an exact time to my server so I wrote the cron job for it BUT the problem is in the date command: /filelog-`date +%Y-%m-%d`.tar.gz; The file... (1 Reply)
Discussion started by: bobo_balde
1 Replies

10. AIX

Commands to call script work from command line but not from Cron entry

My first post evidently did not materialize so I posted it again: Runnning a cron job every 5 mins to send data files to a state facility. My original cron entry at worked fine: 01,06,11,16,21,26,31,36,41,46,51,56 * * * * /home/sftpuser/stateinoc-from-appname.ksh Somewhere I have a... (1 Reply)
Discussion started by: Skyybugg
1 Replies
diaglogd(1M)															      diaglogd(1M)

NAME
diaglogd - Support Tools Manager logging daemon SYNOPSIS
/usr/sbin/stm/uut/bin/sys/diaglogd DESCRIPTION
The Support Tools Manager (STM) uses a logging daemon ( diaglogd ) to read diagnostic events from the kernel via diag2 (diagnostic pseudo driver) and logs them in the system log files. diaglogd is launched automatically at boot by the STM daemon diagmond. The STM User Interface, xstm , mstm , or cstm , Daemon commands can also be used to launch the daemon as well as shut it down and view the daemon's activity log. The log files created by diaglogd can be viewed using the STM utility logtool. Application Usage This daemon will be deprecated on new server models. Please use System Management Homepage (see hpsmh(1M)). WARNINGS
The following message will appear on the system console when the diagnostic logging facility determines that the I/O subsystem has started logging excessive I/O errors. This message will appear only once and I/O errors will be lost until the diagnostic subsystem can recover from this condition. DIAGNOSTIC SYSTEM WARNING: The diagnostic logging facility has started receiving excessive errors from the I/O subsystem. I/O error entries will be lost until the cause of the excessive I/O logging is corrected. If the diaglogd daemon is not active, use the Daemon Startup command in stm to start it. If the diaglogd daemon is active, use the logtool utility in stm to determine which I/O subsystem is logging excessive errors. The following message will appear on the system console when the cause of the excessive I/O error logging is corrected. The total number of I/O errors that were dropped will be placed in "XX". DIAGNOSTIC SYSTEM WARNING: The diagnostic logging facility is no longer receiving excessive errors from the I/O subsystem. XX I/O error entries were lost. OTHER FILES
/dev/diag/diag0 - Series 800 Diagnostic pseudo driver device file /dev/diag/diag1 - Series 700 Diagnostic pseudo driver device file /dev/diag/diag2 - Series 700/800 Diagnostic pseudo driver device file /var/stm/logs/sys/activity_log_diaglogd - Activity log of diaglogd /var/stm/logs/os/log##.raw - OS system log files /var/stm/logs/os/log##.raw.cur - Current OS system log file /var/stm/config/sys/diaglogd.cfg - Diagmond configuration /var/stm/data/daemon_list - List of daemons installed /var/stm/data/key_file - OS resource key file COPYRIGHT
(c) Copyright 1995, Hewlett-Packard Company ORIGIN
diaglogd was developed by Hewlett-Packard Company. SEE ALSO
stm(1M), diagmond(1M) diaglogd(1M)
All times are GMT -4. The time now is 11:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy