Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regularly delete ros log to free space. #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions scripts/auto_start/memory_roslog_monitor.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=ros log memory monitor
After=rm_start.service
[Service]
User=dynamicx
Type=simple
ExecStart=/bin/bash -c "/home/dynamicx/memory_roslog_monitor.sh"
[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions scripts/auto_start/memory_roslog_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
source /opt/ros/noetic/setup.bash
export ROS_PACKAGE_PATH=~/rm_ws:$ROS_PACKAGE_PATH

log_dir=~/.ros/log

if [[ -d "$log_dir" ]]; then
old_dirs=$(find "$log_dir" -type d -mtime +7)
old_files=$(find "$log_dir" -type f -mtime +7)

for dir in $old_dirs; do
rm -rf "$dir"
done
for file in $old_files; do
rm -f "$file"
done
fi