Prerequisites
Before searching logs, make sure you have:
- SSH access to your VPS
- Basic understanding of date formats
Method 1: Using grep (Simple Date Search)
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
Search for today's date:
grep "$(date +'%b %e')" /var/log/syslog
Search for a specific date:
grep "Apr 28" /var/log/syslog
Method 2: Using sed with Date Range
Extract April 25-27 from syslog:
sed -n '/Apr 25/,/Apr 27/p' /var/log/syslog
Method 3: Using journalctl (for systemd logs)
Since yesterday:
sudo journalctl --since=yesterday
Specific date range:
sudo journalctl --since="2026-04-25" --until="2026-04-27"
With time:
sudo journalctl --since="2026-04-28 10:00:00" --until="2026-04-28 12:00:00"
Method 4: Search Rotated Logs (.gz files)
zgrep "Apr 28" /var/log/syslog.2.gz
Method 5: Search All Rotated Logs for Date Range
for log in /var/log/syslog*; do
echo "=== $log ==="
zgrep -a "Apr 28" $log
done
Method 6: Using date command to find yesterday's logs (script)
YESTERDAY=$(date --date="yesterday" +'%b %e')
grep "$YESTERDAY" /var/log/syslog
✅ Logs filtered by date. Use journalctl for most precise time-based search.