#!/bin/bash # crontab starts bash minimally, so export PATH=/usr/local/bin:/usr/bin:/bin # debugging set -eux sudo ip link set can0 down || { echo "Failed to bring down CAN interface"; exit 1; } # NON FD or classical only set up # sudo ip link set can0 type can bitrate 100000 sjw 128 sudo ip link set can0 type can bitrate 100000 sjw 128 dbitrate 400000 fd on sudo ip link set can0 up mkdir -p ~/can_logs cd ~/can_logs/ d=`date` echo "-----------------------------------------------------------" >> can_reset_log.txt /usr/sbin/ifconfig can0 >> can_reset_log.txt echo "CAN NOW RESET" $d >> can_reset_log.txt sudo ip link show can0 >> can_reset_log.txt echo "-----------------------------------------------------------" >> can_reset_log.txt # Compress any old log files # find . -type f -name "*.log" -exec zip {}.zip {} \; # delete uncompressed log files find . -type f -name "*.log" -exec rm -f {} \; /usr/bin/candump -l -t A can0 & # Find and delete .log.zip files older than one month # find . -type f -name "*.log.zip" -mtime +30 -exec rm -f {} \;