Why Logs Disappear After Midnight & How to Find Them
- Average speed
- km/h
- Result
- Finish time
- 50 min
- You entered
- Distance
- 10 km
- You entered
Logs can disappear after midnight because of log rotation, retention policies, or timezone mismatches in the logging system. To find where they went, check the log rotation schedule, the retention settings, and the server’s timezone configuration.
Formula
The calculator works out your average pace and speed from a finish time and distance. The formulas are:
Pace = Finish time (minutes) ÷ Distance (km) → result in minutes per kilometer
Speed = Distance (km) ÷ (Finish time (minutes) ÷ 60) → result in kilometers per hour
Where:
- Finish time (t) – total time taken, in minutes (input)
- Distance (d) – distance covered, in kilometers (input)
- Pace – minutes per kilometer (output)
- Speed – kilometers per hour (output)
Worked Example
Using the default values: finish time = 50 minutes, distance = 10 km.
- Pace = 50 ÷ 10 = 5.00 min/km
- Speed = 10 ÷ (50 ÷ 60) = 10 ÷ 0.8333 = 12.00 km/h
So the calculator returns a pace of 5:00 min/km and a speed of 12.00 km/h.
Why Logs Vanish at Midnight
Most logging systems rotate logs daily, and the rotation often happens at 00:00 server time. When a log file is rotated, the old file is renamed (e.g., app.log becomes app.log.1 or app-2025-01-15.log) and a new empty app.log is created. If you look for entries from the previous day in the main log file after midnight, they are no longer there – they moved to the rotated file. If the rotation also compresses old logs (e.g., to .gz), the previous day’s entries may be in a compressed archive, not in a plain text file.
Common Causes of Missing Logs
- Log rotation – the most common cause; old logs are renamed or compressed at midnight.
- Retention policies – logs older than a set number of days are deleted automatically.
- Timezone mismatch – the server writes logs in UTC but you are looking in local time, so “midnight� for you is a different hour on the server.
- Disk space cleanup – some systems delete logs when disk usage exceeds a threshold, often triggered by a nightly cron job.
- Application restart – some apps truncate or recreate log files on restart, and if a restart happens at midnight, earlier entries may be lost.
How to Find Where the Logs Went
- Check the rotation configuration – look at the logging config (e.g.,
logrotate.confon Linux, or the app’s own logging settings). See if it rotates daily, weekly, or by size, and where it stores old files. - List the log directory – run
ls -la /var/log/(or the app’s log folder) to see if there are files likeapp.log.1,app.log.2.gz, etc. - Search compressed files – use
zgreporzcatto search inside.gzarchives. - Check the server timezone – run
dateon the server and compare with your local time. If the server is UTC and you are UTC+5, “midnight� UTC is 5 AM your time. - Look for a separate archive directory – some systems move old logs to
/var/log/archive/or a dedicated folder.
How to Prevent Logs from Disappearing
- Adjust rotation time – set rotation to run at a time when you are not actively inspecting logs (e.g., 3 AM instead of midnight).
- Increase retention – configure the system to keep more days of logs before deletion.
- Use a centralized logging service – send logs to a remote server or cloud service so they are not lost on the local disk.
- Set a consistent timezone – make all servers and applications use UTC to avoid confusion.
- Monitor disk space – ensure enough free space so cleanup scripts don’t delete logs prematurely.
Common Misconceptions
Many people think logs are “lost� when they are actually just rotated. The data is still on disk, but in a different file. Another misconception is that deleting old logs is always bad – but retention policies are often required by privacy regulations or to save disk space. Also, some assume midnight is a universal time, but servers can be in any timezone, so “midnight� depends on the server’s clock.
Frequently Asked Questions
Why did my log file become empty after midnight?
Log rotation likely created a new empty file and renamed the old one. Check the directory for files with a date or number suffix – your previous entries are there.
How do I search logs that were rotated and compressed?
Use zgrep or zcat on .gz files. For example: zgrep "error" /var/log/app.log.2.gz.
Can I recover logs that were deleted by retention policy?
If the files were overwritten on disk, recovery is difficult. Check if you have backups or a centralized logging system. For the future, increase retention or set up regular backups.
Why do logs disappear at midnight but not at other times?
Most rotation jobs are scheduled at midnight because it’s a natural boundary. It’s also a common time for cron jobs that clean up old files.
How do I change the log rotation time on Linux?
Edit the /etc/logrotate.conf or the specific config in /etc/logrotate.d/ and change the hourly or daily directive, or use a cron job to run logrotate at a different time.
Is it safe to delete old log files?
Only if you have a retention policy that allows it. Check legal requirements and whether you need logs for debugging or security audits. When in doubt, archive them instead of deleting.
Related
Formula used
in t | Finish time | min | 50 | 0 in d | Distance | km | 10 | 0 out pace | Average pace | min/km | t / d | 2 out speed | Average speed | km/h | d / (t / 60) | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.