Sponsored Content
Top Forums Shell Programming and Scripting Syntax for sudoers file for mv command Post 303037797 by ron323232 on Tuesday 13th of August 2019 07:22:49 PM
Old 08-13-2019
Syntax for sudoers file for mv command

Hi,

On one of Solaris 10 server, apache service is running. Due to audit requirement, its error_log grows bigger and we are required to keep that. Sometimes it grows more than 200GB and fills up file-system.
Purpose is, if error_log touches 10GB, apache service should stop, error_log should move to error_log_xxxxxx and spache service start.
Application team wants to use a script, which looks straightforward. Below is part of that script
Code:
       logger -p user.alert "ChkProxyStatus.sh :: proxy_health_warning :: Apache error log was exceeding 10G. Restarting apache on $Server."
       mv $LatestErrorFile ${LatestErrorFile}_`date +%Y%m%d`
       /usr/local/bin/sudo /usr/sbin/svcadm restart svc:/site/network/http:apache2
       sleep  10
       Status=`/usr/bin/svcs |grep http | grep -c 'online'`

error_log is owned by root, so application user (which will run that script via his cron) will not be able to mv that file. If I can give 'sudo mv' to his id with absolute path, this should serve the purpose, I think.
But I am not able to figure out, what should be syntax in /etc/sudoers for mv command mentioned in above script.
Help please.

Thanks
 

10 More Discussions You Might Find Interesting

1. Linux

sudoers file

Hi, I have edited 'sudoers' file to allow 'cads' user shutdown the system without providing a password. Can someone tell me what's wrong with my file? It's not working when I 'sudo SHUTDOWN' command: sudo: SHUTDOWN: command not found Thanks a lot! # Host alias specification... (4 Replies)
Discussion started by: whatisthis
4 Replies

2. Solaris

sudoers file not found

root@dervish # cat /etc/sudoers cat: cannot open /etc/sudoers This is what I get when I try to search for the sudoers files. I want to create a user by name jda and assign him root privileges. How can I do that using sudo command and editing sudoers file. Please help me. (12 Replies)
Discussion started by: bharu_sri
12 Replies

3. UNIX for Advanced & Expert Users

sudoers syntax

I'm stuck with a dilemma. I am trying to control userid's access to the su command in such a way that he will not be able to su to root (su, su -, su root, su - root) but he will be able to su to any other user. I have tried the following syntax: userid ALL=/usr/bin/su ?*, !/usr/bin/su *root*... (2 Replies)
Discussion started by: chuckuykendall
2 Replies

4. UNIX for Advanced & Expert Users

sudoers file

i have defined a rule in the sudoers file so a specific user is able to run some commands as sudo with no password. my question is: is it possible to restrict a user to run commands as sudo only in a certain directory? for example: chown only the files that are located in /var/tmp. Thank you. ... (2 Replies)
Discussion started by: noam128
2 Replies

5. UNIX for Dummies Questions & Answers

how to take backup of a file , tell command and syntax

how to take backup of a file , tell command and syntax (1 Reply)
Discussion started by: sunilamarnadh
1 Replies

6. Cybersecurity

Help with sudoers file - AIX

Hi all, I'm trying to setup my sudoer file at work to have the right security, but I'm not able to refine to the level I want. Here's what I would like to have: => OS Users - John (group staff) - Bob (group staff) - app20adm (group app20grp) - app70adm (group app70grp) - sys20adm... (0 Replies)
Discussion started by: victorbrca
0 Replies

7. UNIX for Dummies Questions & Answers

Pls. help with sudoers file...

Hi, I was asked to create sudoers file for operation team so they can sudo as another user and run few commands. I have updated /etc/sudoers file. User_Alias LEVEL1 = JamesF, dennisW, juanC, steveS, Cmnd_Alias SU_PROD=/bin/su prod, /bin/su - prod Cmnd_Alias SU_NYOP=/bin/su... (2 Replies)
Discussion started by: samnyc
2 Replies

8. Emergency UNIX and Linux Support

Getting details from sudoers file

Hi, I need the details of which ids belong to the sudoers file, and which groups these ids belong to. Can anyone suggest a way to derive that information into a flat file please? G (4 Replies)
Discussion started by: ggayathri
4 Replies

9. UNIX for Dummies Questions & Answers

Help with Sudoers file

Hi using Solaris 10. trying to update /etc/sudoers file I need to add all the fist level operation team. This is what I have but it doesn't seem to work. Please help.Error message sudo su - >>> sudoers file: parse error, line 9 <<< >>> sudoers file: parse error, line 9 <<< ... (2 Replies)
Discussion started by: samnyc
2 Replies

10. Solaris

Sudoers file

In the sudoers file in Solaris... I am trying to limit the DEVELOPER user privileges to where those users can only use the “rm” command in certain directories. This is to prevent them from deleting directories or files and destroying a server. I want them to be able to use the "rm" command but... (1 Reply)
Discussion started by: nzonefx
1 Replies
DBI::ProfileDumper::Apache(3)				User Contributed Perl Documentation			     DBI::ProfileDumper::Apache(3)

NAME
DBI::ProfileDumper::Apache - capture DBI profiling data from Apache/mod_perl SYNOPSIS
Add this line to your httpd.conf: PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache (If you're using mod_perl2, see "When using mod_perl2" for some additional notes.) Then restart your server. Access the code you wish to test using a web browser, then shutdown your server. This will create a set of dbi.prof.* files in your Apache log directory. Get a profiling report with dbiprof: dbiprof /path/to/your/apache/logs/dbi.prof.* When you're ready to perform another profiling run, delete the old files and start again. DESCRIPTION
This module interfaces DBI::ProfileDumper to Apache/mod_perl. Using this module you can collect profiling data from mod_perl applications. It works by creating a DBI::ProfileDumper data file for each Apache process. These files are created in your Apache log directory. You can then use the dbiprof utility to analyze the profile files. USAGE
LOADING THE MODULE The easiest way to use this module is just to set the DBI_PROFILE environment variable in your httpd.conf: PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache The DBI will look after loading and using the module when the first DBI handle is created. It's also possible to use this module by setting the Profile attribute of any DBI handle: $dbh->{Profile} = "2/DBI::ProfileDumper::Apache"; See DBI::ProfileDumper for more possibilities, and DBI::Profile for full details of the DBI's profiling mechanism. WRITING PROFILE DATA The profile data files will be written to your Apache log directory by default. The user that the httpd processes run as will need write access to the directory. So, for example, if you're running the child httpds as user 'nobody' and using chronolog to write to the logs directory, then you'll need to change the default. You can change the destination directory either by specifying a "Dir" value when creating the profile (like "File" in the DBI::ProfileDumper docs), or you can use the "DBI_PROFILE_APACHE_LOG_DIR" env var to change that. For example: PerlSetEnv DBI_PROFILE_APACHE_LOG_DIR /server_root/logs When using mod_perl2 Under mod_perl2 you'll need to either set the "DBI_PROFILE_APACHE_LOG_DIR" env var, or enable the mod_perl2 "GlobalRequest" option, like this: PerlOptions +GlobalRequest to the global config section you're about test with DBI::ProfileDumper::Apache. If you don't do one of those then you'll see messages in your error_log similar to: DBI::ProfileDumper::Apache on_destroy failed: Global $r object is not available. Set: PerlOptions +GlobalRequest in httpd.conf at ..../DBI/ProfileDumper/Apache.pm line 144 Naming the files The default file name is inherited from DBI::ProfileDumper via the filename() method, but DBI::ProfileDumper::Apache appends the parent pid and the current pid, separated by dots, to that name. Silencing the log By default a message is written to STDERR (i.e., the apache error_log file) when flush_to_disk() is called (either explicitly, or implicitly via DESTROY). That's usually very useful. If you don't want the log message you can silence it by setting the "Quiet" attribute true. PerlSetEnv DBI_PROFILE 2/DBI::ProfileDumper::Apache/Quiet:1 $dbh->{Profile} = "!Statement/DBI::ProfileDumper/Quiet:1"; $dbh->{Profile} = DBI::ProfileDumper->new( Path => [ '!Statement' ] Quiet => 1 ); GATHERING PROFILE DATA Once you have the module loaded, use your application as you normally would. Stop the webserver when your tests are complete. Profile data files will be produced when Apache exits and you'll see something like this in your error_log: DBI::ProfileDumper::Apache writing to /usr/local/apache/logs/dbi.prof.2604.2619 Now you can use dbiprof to examine the data: dbiprof /usr/local/apache/logs/dbi.prof.2604.* By passing dbiprof a list of all generated files, dbiprof will automatically merge them into one result set. You can also pass dbiprof sorting and querying options, see dbiprof for details. CLEANING UP Once you've made some code changes, you're ready to start again. First, delete the old profile data files: rm /usr/local/apache/logs/dbi.prof.* Then restart your server and get back to work. OTHER ISSUES
Memory usage DBI::Profile can use a lot of memory for very active applications because it collects profiling data in memory for each distinct query run. Calling "flush_to_disk()" will write the current data to disk and free the memory it's using. For example: $dbh->{Profile}->flush_to_disk() if $dbh->{Profile}; or, rather than flush every time, you could flush less often: $dbh->{Profile}->flush_to_disk() if $dbh->{Profile} and ++$i % 100; AUTHOR
Sam Tregar <sam@tregar.com> COPYRIGHT AND LICENSE
Copyright (C) 2002 Sam Tregar This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. perl v5.16.2 2010-06-08 DBI::ProfileDumper::Apache(3)
All times are GMT -4. The time now is 09:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy