- Ubuntu Server 14.04 – Disable IPv6
- Ubuntu Server 18.04 – Postfix 3.3.0 Issues
- Ultra VNC – Send Custom Keys Workaround and ASCII Reference Chart
- UltraVNC – Password Not Set: How to Install as a System Service
- uTorrent – Don’t Have Permission to Uninstall the Program
- VBScript – Get a Folder/File Size or Verify That a Folder/File Exists
- VBScript – How to Access Environment Variables -OR- How to Get the Username, Domain, or a User’s SID
- VMware vSphere Client – Remove Cached Entries on Connection Screen
- Windows – How to Run Elevated Scripts as a Regular User with Task Scheduler -OR- How to Restart Services as a Standard User
- Windows – Play a WAV file with PowerShell and the .NET SoundPlayer Class
- Windows 8.1 – Disable IPv6 Components
- Windows 8/Server 2012 – Install A Theme for All Users
- Windows Explorer – Cannot Read From the Source File or Disk
- Windows Server – Disable VMware Tools Icon
- Windows Server 2K P2V Conversion VMware BSOD
- Windows Terminal Server – Three Ways to Disable AVG Tray Icon via Group Policy
- Windows Update Error 80073712 When Installing KB2943357 – OR – How to Repair Corrupted Windows Update Files on Windows 7 or Server 2008
- Windows Update Error 8024402C – Bypass WSUS for VPN Computers Joined to the Domain
- Windows XP – VMware Standalone Converter Install Sysprep Tools
- WinSCP – Import/Export Your Saved Sessions List and Settings from a Computer that is Offline
Bash Script – Pcapsipdump Spool Directory File Rotation – OR – Rotate Directories Based on YYYYMMDD Format
In the config file for the pcapsipdump program, there is a retention option where you are supposed to be able to enter the number of days to keep the directories in your spool folder and it should auto purge out the old directories/files, however, this option either doesn’t appear to be implemented yet or doesn’t work if you run the app as a different user (could be a permissions issue maybe?).
Anyhow, this script is my solution to the problem. It could also very easily be modified and used where someone needs to search and delete directories that are based on YYYYMMDD format with the ability to whitelist or ignore certain directories, hence the alternate title. Yet another alternate title could even be “Bash Script Functions – Convert YYYYMMDD to Unix Time and Vice Versa” but obviously the script would need modified a little because it has been tailored to fit my needs.
When run as a cron job, the script will grab both the spool directory and the retention period from the pcapsipdump config file and will purge out any old folders based on YYYYMMDD format so they aren’t eating up all your valuable disk space.
I also added a couple of noteworthy user-configurable options. The first being a directory whitelist feature (IGNORE_DIRS array), this option can be used in situations where there are directories that you don’t want purged or would like to keep the data indefinitely and that can also be used in conjunction with the PURGE_ALL feature to delete out any subdirectories that aren’t specifically listed in the whitelist if you are a clean freak.
Download it now – pcaprotate.sh
#!/bin/bash # # pcapsipdump file rotation # By Nathan Thomas # 12/05/2014 # ### VARS ### # Location of the pcapsipdump config file CONF_FILE='/etc/default/pcapsipdump'; # Keep the spool folder clean - Delete all folders (except those in the ignored directories array) # yes - Keep the spool folder free from any directories not in the ignore list # no - Don't worry about any other random folders in the spool directory Continue reading "Bash Script – Pcapsipdump Spool Directory File Rotation – OR – Rotate Directories Based on YYYYMMDD Format"