Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
= logrotate
== DESCRIPTION:
This package is a library of methods that perform log rotation on files and directories. The log rotate methods allow the caller to specify options (via parameters) such as how many rotated files to keep, what type of extension to place on the rotated file (date or a simple count), and whether to zip the rotated files. Live log files (currently being written to by a live process) can be rotated as well. The post_rotate option is useful in that context, as it can be used to send a HUP signal to notify the live process to reopen its log file.
This package was inspired by the need to have a library version of the unix logrotate tool. The unix logrotate tool requires the user to specify options in a config file, and is usually invoked through cron.
Directories can be rotated with this library. However, the gzip option does not work with directories. In this case, please zip/tar the directory in question before invoking this library.
== PROBLEMS:
None (known).
== SYNOPSIS: Here are some sample invocations of the library.
Rotate a log file with date/time extensions. ======examples/rotate_date_time.rb: #!/usr/bin/env/ruby
require 'fileutils' require 'rubygems' require 'logrotate'
options = { :date_time_ext => true, :date_time_format => '%F_%T', :count => 2 }
1.upto(3) do |iteration|
FileUtils.touch("/tmp/erwin.dat") result = LogRotate.rotate_file("/tmp/erwin.dat", options)
print "=================================================\n" print "Iteration ##{iteration}\n" print "=================================================\n" print result, "\n"
sleep(1.5) end
FileUtils.rm_f(Dir.glob('/tmp/erwin.dat.*'))
Rotated Files And Dates: file -> /tmp/erwin.dat.2008-08-21_12:37:39, date_time -> 2008-08-21T12:37:39+00:00 file -> /tmp/erwin.dat.2008-08-21_12:37:37, date_time -> 2008-08-21T12:37:37+00:00 Rotated Files: /tmp/erwin.dat.2008-08-21_12:37:39 /tmp/erwin.dat.2008-08-21_12:37:37 Deleted Files: New Rotated File: /tmp/erwin.dat.2008-08-21_12:37:39
Rotated Files And Dates: file -> /tmp/erwin.dat.2008-08-21_12:37:41, date_time -> 2008-08-21T12:37:41+00:00 file -> /tmp/erwin.dat.2008-08-21_12:37:39, date_time -> 2008-08-21T12:37:39+00:00 Rotated Files: /tmp/erwin.dat.2008-08-21_12:37:41 /tmp/erwin.dat.2008-08-21_12:37:39 Deleted Files: /tmp/erwin.dat.2008-08-21_12:37:37 New Rotated File: /tmp/erwin.dat.2008-08-21_12:37:41
Rotated Files And Dates: file -> /tmp/erwin.dat.2008-08-21_12:37:42, date_time -> 2008-08-21T12:37:42+00:00 file -> /tmp/erwin.dat.2008-08-21_12:37:41, date_time -> 2008-08-21T12:37:41+00:00 Rotated Files: /tmp/erwin.dat.2008-08-21_12:37:42 /tmp/erwin.dat.2008-08-21_12:37:41 Deleted Files: /tmp/erwin.dat.2008-08-21_12:37:39 New Rotated File: /tmp/erwin.dat.2008-08-21_12:37:42
Rotate a set of log files with date extensions, and move the rotated files to a specified directory: ======examples/rotate_date.rb: #!/usr/bin/env ruby
require 'fileutils' require 'rubygems' require 'logrotate'
output_directory = "/tmp/archives" if (!File.directory?(output_directory)) then Dir.mkdir(output_directory) end
files = (1..64).map {|i| "/tmp/erwin_#{i}.dat" } files.each do |file| File.open(file, "w") do |fs| fs.write(file) end end
options = { :date_time_ext => true, :directory => output_directory }
LogRotate.rotate_files(files, options)
FileUtils.rm_f(Dir.glob"/tmp/erwin*.dat") FileUtils.rm_rf("/tmp/archives")
Rotate a log file with simple extensions: .1, .2, etc, keep 3 rotated files around (.1 .. .3), and gzip the rotated files (.1.gz, .. .3.gz): ======examples/rotate_count.rb: #!/usr/bin/env ruby
require 'fileutils' require 'rubygems' require 'logrotate'
options = { :count => 2, :gzip => true }
1.upto(3) do |iteration|
FileUtils.touch("/tmp/erwin.dat") result = LogRotate.rotate_file("/tmp/erwin.dat", options)
print "=================================================\n" print "Iteration ##{iteration}\n" print "=================================================\n" print result, "\n" end
FileUtils.rm_f(Dir.glob('/tmp/erwin.dat.*'))
Rotated Files And Counts: file -> /tmp/erwin.dat.1.gz, index -> 1 Rotated Files: /tmp/erwin.dat.1.gz Deleted Files: New Rotated File: /tmp/erwin.dat.1.gz
Rotated Files And Counts: file -> /tmp/erwin.dat.1.gz, index -> 1 file -> /tmp/erwin.dat.2.gz, index -> 2 Rotated Files: /tmp/erwin.dat.1.gz /tmp/erwin.dat.2.gz Deleted Files: New Rotated File: /tmp/erwin.dat.1.gz
Rotated Files And Counts: file -> /tmp/erwin.dat.1.gz, index -> 1 file -> /tmp/erwin.dat.2.gz, index -> 2 Rotated Files: /tmp/erwin.dat.1.gz /tmp/erwin.dat.2.gz Deleted Files: /tmp/erwin.dat.2.gz New Rotated File: /tmp/erwin.dat.1.gz
Rotate a log file that is currently being written to by a live
process. After the file is rotated, notify the live process to reopen
its log file.
======examples/rotate_live.rb:
#!/usr/bin/env ruby
require 'fileutils' require 'rubygems' require 'logrotate'
block = Proc.new() do File.open("/tmp/hupper.pid") do |pid_stream| pid = pid_stream.read().to_i() Process.kill("HUP", pid) end end
options = { :gzip => true, :count => 3, :post_rotate => block }
LogRotate.rotate_file("/tmp/hupper.dat", options)
FileUtils.rm_rf(Dir.glob("/tmp/hupper*"))
== REQUIREMENTS:
== INSTALL:
sudo gem install logrotate
== AUTHORS: === Designing Patterns
== SUPPORT: Please post questions, concerns, or requests for enhancement to the forums on the project page. Alternatively, direct contact information for Designing Patterns can be found on the project page for this gem.
== ENHANCEMENTS: Please feel free to contact us with any ideas; we will try our best to enhance the software and respond to user requests. Of course, we are more likely to work on a particular enhancement if we know that there are users who want it. Designing Patterns provides contracting and consulting services, so if there is an enhancement that must get done (and in a specified time frame), please inquire about retaining our services!
== LICENSE: The license text can be found in the +LICENSE+ file at the root of the distribution.
This package is licensed with an MIT license:
Copyright (c) 2008-2009 Designing Patterns
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
== SHARE AND ENJOY!
FAQs
Unknown package
We found that logrotate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.