Robotics StackExchange | Archived questions

Conditional emptying of log files for node without deleting the file

Dear Experts,

As per my system architecture there is a need to take archives of logs under ~/.ros/log/latest/ folder. However in our operation we are not allowed to stop and restart rosmaster and all the nodes. Hence the symlink of the latest folder will be perennial as well as the log files will be appended each time the node is exercised. What we need is to clear the content of the *.log files on an event (which could be read from a suitable rostopic). The event marks a culmination of a particular cycle of oepration and hence the logs between the event is relevant for relating it to a cycle.

The command

rosclean purge -y

Is not helpful as it clears off the folder and the handle to the files are lost. After that unless and until the all the nodes and rosmaster is restarted the logging will not commence.

Is there a way we can issue emptying of the *.log files on an event with the constraint that the rosmaster and nodes cannot be shutdown/killed.

The following crude solultion does not yield proper result

for logs in ~/.ros/log/latest/*.log; do
echo "" > $logs
done

Any help will be appreciated

Regards Shouvik

Asked by shouvik1984 on 2023-03-15 06:57:29 UTC

Comments

Answers

Is there a way we can issue emptying of the *.log files on an event with the constraint that the rosmaster and nodes cannot be shutdown/killed.

In the context of ROS 1, this is not supported by any of the provided, standard functionality.

That's not to say it might not be possible to implement a work-around, but at least in the standard tooling, what you describe is not supported.

Asked by gvdhoorn on 2023-03-15 08:16:09 UTC

Comments

Unattended remote systems have the rosmaster running indefinitely (unless there is a maintainance needed). During that time we cannot issue rosclean. We are looking for ways and means to keep periodically cleaning the roslogs so that it does not occupy immense amount of space.

Please suggest.

Asked by shouvik1984 on 2023-03-17 06:26:51 UTC

We handle this problem using the --screen option to roslaunch. This redirects all log messages to stdout/stderr, giving our code control of log message storage and rotation.

It's a good idea to set environment variable PYTHON_UNBUFFERED=1 for roslaunch in order to suppress the internal stdout/stderr buffering done by python.

Asked by Mike Scheutzow on 2023-03-17 06:57:04 UTC

Comments

Actually as the system is remote and unattended, logs are needed for prognostics for analyzing if there are some unexpected behavior, hence we cannot affort to use output:=screen. As the remote it is going to run the rosmaster and the nodes continuously. Is there a way we can keep changing the log file name during each new event?

Asked by shouvik1984 on 2023-03-17 07:30:21 UTC