The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Info req: /var/adm/messages - Kern.warning - different ID messages Petrucci SUN Solaris 1 12-04-2008 01:30 PM
Command to display nth line before the string is matched. helper UNIX for Advanced & Expert Users 5 11-05-2008 12:08 PM
A utility for sending complex email messages from the command line iBot UNIX and Linux RSS News 0 06-06-2008 05:50 AM
Display Printers via command line gseyforth Windows & DOS: Issues & Discussions 3 06-28-2006 02:02 AM
how to concatenate two command in one line and get the display in one screen vasikaran UNIX for Dummies Questions & Answers 9 07-01-2005 06:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-21-2009
Danish Shakil Danish Shakil is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 35
display warning messages on command line

I have made a script to print size of a slice if it reaches more then 80% which is working fine no problem in it.

I want to add this script in crontab to print this message on command line every half hour if slice size reaches more then 80%.
here is the line below i added on crontab

30 * * * * /osp/local/home/linus/test.sh

The problem is crontab is running but not displaying any text on command line, i cheched it by redirecting test.sh


Code:
#cat test.sh
 
#/usr/sbin/ksh
#set -x
df -k | grep var |grep c1t0d0s3 > test.txt
cat test.txt | nawk -F " " '{printf "%s\n" , $5}' > test1.txt
#m=`cut -d " " -f 1 test1.txt`
sed 's/%//g' test1.txt > red3
m=`cut -d " " -f 1 red3`
if [ $m -gt 80 ];
then
echo your /var size is $m% kindly remove some space"
echo
fi
 
#
#

  #2 (permalink)  
Old 02-21-2009
unSpawn unSpawn is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 53
Quote:
Originally Posted by Danish Shakil View Post
crontab is running but not displaying any text on command line
If Syslog is configured to dump certain facility.priority level messages to the console you could check 'logger'. Or maybe else check 'write' or 'wall' but I don't know if crond process owner would be allowed that.
  #3 (permalink)  
Old 02-22-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,365
Quote:
Originally Posted by Danish Shakil View Post
The problem is crontab is running but not displaying any text on command line, i cheched it by redirecting test.sh

Which command line would you want cron to print to? How could it know?
Quote:


Code:
#cat test.sh
 
#/usr/sbin/ksh
#set -x
df -k | grep var |grep c1t0d0s3 > test.txt
cat test.txt | nawk -F " " '{printf "%s\n" , $5}' > test1.txt
#m=`cut -d " " -f 1 test1.txt`
sed 's/%//g' test1.txt > red3
m=`cut -d " " -f 1 red3`
if [ $m -gt 80 ];
then
echo your /var size is $m% kindly remove some space"
echo
fi
 
#
#

Code:
m=$( df -k | 
nawk -F " " '/var/ && /c1t0d0s3/ {
 sub( /%/, "", $5)
 printf "%s\n" , $5 }'
)

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0