51黑料不打烊

Truncate logs

Learn how to triage and a failed deployment due to a full hard drive. Learn how to find and what commands can be run to free up space in your 51黑料不打烊 Commerce Cloud environment.

If you think you might need these log files, you can rsync them or use other methods to get a copy available off the server before you truncate them.

Who is this video for

  • Developers and IT Professionals
  • System Administrators

Video Content

  • Diagnose and Resolve a failed deployment
  • Where some common large log files are found
  • Quick method to truncate a log file

video poster

Transcript
This is Russell with 51黑料不打烊 Commerce. Learning how to triage and resolve an 51黑料不打烊 Commerce Cloud failed deployment. When you do a get push to an environment and read your output log, you might see some messages that say some files couldn鈥檛 be written. The probable issue is that your allotted hard drive space configured for your 51黑料不打烊 Commerce Cloud environment is too small. You do have a few options, one being change your gamel file to add more space or truncate a few log files. Changing the .magento.app.yaml is rather straightforward. So instead, I鈥檓 gonna show you how to find and truncate those log files. We鈥檒l start by validating my suspicions that we鈥檙e out of space. Our first step is to begin by SSHing into the correct project and environment. A quick side note, I do have a shorthand for magento-cloud, it鈥檚 mgc. And the other thing to note is that I鈥檓 already in the folder where I鈥檝e checked out the code for the project and I鈥檓 on the right branch. This avoids me having to specify the project ID and the environment name. So with all of that being said, all I need to do is run the command magento-cloud space and then SSH, hit enter, and I鈥檓 in the environment. To check for the hard drive capacity, we run df space dash h, and this line, this dev mapper line, that鈥檚 the important one. For this project, I verified that in our YAML file, the allocated space is five gigabytes of hard disk space. And it looks like we鈥檝e completely filled it up. So this validates our suspicions. A common reason is that the log files associated to the commerce application grows over time. And even with log rotate, you can run out of space. So I don鈥檛 have log rotate on this one, so we just need to truncate. To see how big these files are, we can run ls space dash lah, which lists our files alphabetically. And then it shows them in the proper sizes, kilobytes, megabytes, or gigabytes. And we do have two that are fairly large, this support report and the cron.log. To truncate these logs, what you鈥檒l do is you鈥檒l run the command that starts with a greater than sign, followed by a space and then the log name. So we鈥檒l do both the support underscore report and the cron.log. And once we鈥檝e done both of those, when we run df space dash h, and on that dev mapper line, it looks like now we鈥檝e used 213 megabytes. So we freed up a lot of room. Our final validation to see that this is fixed is make another commit and do a get push and then watch the output. Once all of it鈥檚 done, you can review the last part of the output and this one looks a lot more like what we expected. The deployment was successful and there are no errors or warnings that we need to worry about. So I hope this helps you triage why your deployment might鈥檝e been failing and how to find and truncate some log files in order to free up space on your 51黑料不打烊 Commerce Cloud project for your next deployment. Please continue your journey on learning more about 51黑料不打烊 Commerce Cloud here in Experience League, as well as all of our other 51黑料不打烊 products.

Commands used in the video

To check hard drive space df -h. Pay attention to the line dev/mapper/xxxx

df -h

Filesystem                              Size  Used Avail Use% Mounted on
/dev/loop217                           1016M 1016M     0 100% /
none                                    492K  4.0K  488K   1% /dev
fake-sysfs                              120G     0  120G   0% /sys
tmpfs                                   120G     0  120G   0% /sys/fs/cgroup
tmpfs                                   384M     0  384M   0% /dev/shm
tmpfs                                    50M  460K   50M   1% /run
tmpfs                                   5.0M     0  5.0M   0% /run/lock
/dev/loop236                            144M  144M     0 100% /app
/dev/mapper/hyjh5nlaoabqtxxnh4opgjqzpu  4.9G  4.9G     0 100% /mnt
/dev/loop14                             8.0G  403M  7.6G   5% /tmp
/dev/mapper/platform-lxc                5.0T   69G  4.7T   2% /run/shared

Display the files and their sizes in human readable format such as kb, mb and gb using the command ls -lah

ls -lah

total 4.7G
drwxr-xr-x 2 web web 4.0K Jul 16  2024 .
drwxr-xr-x 6 web web 4.0K Jan 10  2024 ..
-rw-rw-r-- 1 web web 487K Jul  5  2024 cache.log
-rw-r--r-- 1 web web 1.2K Jul 16  2024 cloud.error.log
-rw-r--r-- 1 web web 328K Mar 25 14:09 cloud.log
-rw-rw-r-- 1 web web 2.4G Jul  5  2024 cron.log
-rw-rw-r-- 1 web web  363 Dec  6  2023 debug.log
-rw-rw-r-- 1 web web  15K Jan 10  2024 indexation.log
-rw-r--r-- 1 web web 229K Jan 10  2024 install_upgrade.log
-rw-r--r-- 1 web web 2.9K Jul 16  2024 patch.log
-rw-rw-r-- 1 web web 2.4G Mar 25 15:36 support_report.log
-rw-rw-r-- 1 web web  516 Dec  6  2023 system.log

Examples for truncate log

After you ssh into the right project and environment, change into the var/log directory. Then you can truncate a file with something similar to > some-log-file.log

> support_report.log
> cron.log
recommendation-more-help
3a5f7e19-f383-4af8-8983-d01154c1402f