stop logging when executing a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting stop logging when executing a script
# 1  
Old 08-23-2008
stop logging when executing a script

Hi guys if for every command you issued successfully where to be logged from a script and them sent an email to the admistrator how could i stop that so that i wouldnt have to delete admin mail all the time. I would only want to produce output if there was an error.
# 2  
Old 08-23-2008
Are you talking about a shell script? If so, what shell?
# 3  
Old 08-24-2008
bash

just bash shell script
# 4  
Old 08-24-2008
Bash scripts do not normally cause anything to be logged anywhere. Perhaps you can describe the scenario and environment where this is happening in a bit more detail.

On a hunch, I'm guessing you might be talking about a cron job or similar which generates output which then gets sent to the administrator. In general terms, you can suppress regular output by redirecting it to /dev/null, like so:

Code:
verbosecommand >/dev/null

If verbosecommand is correctly implemented, error messages will not be suppressed by this redirection (this is why we have separate "standard output" and "standard error"; the above discards only the "standard output").
# 5  
Old 08-24-2008
yes i am talking about a cron job so if this script where to run as a cron job process and it would send mail to the administrator. I would only want it to send error messages to the log file. Would the above work ok?
# 6  
Old 08-24-2008
That's the idea, yes. To be on the safe side, perhaps you can start by redirecting to a real file, instead of /dev/null, and check after the job completes that the file doesn't contain useful information. If the job is a shell script (or, for that matter, a binary that you have the source code for), it might be a useful exercise to change it so it doesn't emit spurious output, in keeping with a great Unix design principle. Maybe there could be a separate --quiet option for this.

In order to be able to test this without waiting for cron to kick in, and also to keep your crontab simple, you might want to create a wrapper script which sets up the redirections etc, and invoke that from your crontab instead of the real thing.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Set -n doesn't stop executing

When I do "set -n" or "set -o noexec" the shell doesn't do what it sould. Infact if I check: $: set -o .... noexec off .... f ...instead I can set normally the other option. Who Knows what could be up? (2 Replies)
Discussion started by: flaviofachin
2 Replies

2. Linux

Syslog not logging successful logging while unlocking server's console

When unlocking a Linux server's console there's no event indicating successful logging Is there a way I can fix this ? I have the following in my rsyslog.conf auth.info /var/log/secure authpriv.info /var/log/secure (1 Reply)
Discussion started by: walterthered
1 Replies

3. Web Development

How to stop my the logging of my IP address?

A Gbytes long log /var/log/apache2/access_log causes my question: How to stop my IP logging (just because of frequent AJAX/setTimeout). As config: SetEnvIf Remote_Addr "ip\.ip\.ip\.ip" dontlog CustomLog /var/log/apache2/access_log common env=!dontlog In /etc/apache2/httpd.conf ... (0 Replies)
Discussion started by: Xcislav
0 Replies

4. Shell Programming and Scripting

Logging Script!!!

I am trying to write a script that can be called by other scripts to print output to a log. I also want to be able to rotate the log file for this script with a max of 5 logs files. This is what I have so far: #/bin/ksh . /taipso75/scripts/IPSM_run_profile.sh* log=${IPSM_HOME}/log ( echo... (1 Reply)
Discussion started by: Dougj75
1 Replies

5. Shell Programming and Scripting

Stop child script by stoping parent script

Hi everyone, I have this problem with a script I'm writting. I want to execute a code running in the background several times through a script. I am writting it like that parent_script for a in 1 2 3 4 5 do exec test -n $a done What I want to do is when parent_script is killed,... (0 Replies)
Discussion started by: geovas
0 Replies

6. Shell Programming and Scripting

Executing scipts after logging into a remote host using shell script

Hi All, Sorry if it is a duplicate post. I have not got any reference about this anywhere. I looked at the posts described in SSH - Passing Unix login passwords through shell scripts - Linux / UNIX Forum and it helped me till the point to connect to the host and executing the basic commands.... (3 Replies)
Discussion started by: RSC1985
3 Replies

7. Shell Programming and Scripting

How to stop a script running in remote server from local script

Hi, I have googled for quite some time and couldn't able to get what exactly I am looking for.. My query is "how to stop a shell script which is running inside a remote server, using a script"??? can any one give some suggestions to sort this out. (1 Reply)
Discussion started by: mannepalli
1 Replies

8. Solaris

stop wtmpx logging

Hello One of our applications initiates an ftp logon to itself twice every second ...(to check some files or something im not sure) but every time it does this it logs an entry into the wtmpx database, this file is now getting absolutely huge and whilst I know that I could implement some type of... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

9. Solaris

editing syslog to stop a particular daemon logging

Hi there I get the following message im my messages file 2 or 3 times a second Dec 4 11:44:18 my-box in.timed: connect from localhost I would like to stop in.timed from logging to syslog altogether as this message is filling up my disk. I dont want to stop daemon.info altogether... (0 Replies)
Discussion started by: hcclnoodles
0 Replies

10. UNIX for Dummies Questions & Answers

logging as su from script

Hi, I am running a script where i need to run another command in a particular folder which I do not have access so I need to login as su to that folder and run that script...what are the options I need so that I can skip interactive mode ..here is what I tried.. #! /usr/bin/sh... (2 Replies)
Discussion started by: mgirinath
2 Replies
Login or Register to Ask a Question