When crontab runs the script, the log log file is very large, and it is very slow to open it with vim.

how to solve the problem that when crontab runs a script, the log log file is very large and stuck when it is opened by vim?

Jul.23,2021

if you only want to view the log, not to edit it, it is not necessary to use vim to open it.

for simple viewing, you can use a combination of tools such as less/head/grep/awk/cut/grok.

or use some professional log analysis tools to open, open your search engine, I believe you can find many tools you want


logs are not normally opened by vim, because you don't need to edit anything. The greatest function is to view and analyze.

for simple viewing and browsing, it is usually tac test.log | more page to view.

for simple statistics, you can also use the awk command to count some simple data.


you can use the tail command to view the newly printed log, and if you need to view it in real time, use tail-f .


in order to prevent the log file from being too large, it is recommended to split the log into small files instead of writing all the logs in one file.
for example, daily log is a file, or a fixed file size log file, or perform a task to record one log file.
this allows you to narrow the file range when you want to troubleshoot problems, and you can write programs to package and compress a lot of logs from a long time ago, reducing space usage.


head-n 10 logfile View the first 10 lines
tail-n 10 logfile View the last 10 lines
cat logfile | less turn the page

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3fd73-2c4a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3fd73-2c4a8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?