Cleanup GitLab Runner Docker Cache

If you have a self-hosted GitLab Runner with Docker executor, you need to periodically clean up Docker containers and volumes left by job executions. Otherwise, the runner machine will eventually run out of space. GitLab Runner installation comes with a script designed to accomplish cleanup: /usr/share/gitlab-runner/clear-docker-cache To see how much space can be reclaimed, run: sudo /usr/share/gitlab-runner/clear-docker-cache space To run cleanup every Sunday at 2:00 AM, add the following using the sudo crontab -e command: ...

July 28, 2025 · 1 min · 81 words · Maxim

Change to Previous Working Directory

When working in the Linux or macOS console, I sometimes find myself in a directory I didn’t intend to be in (for example, after accidentially running cd without arguments, which takes you to your home directory). Manually typing the previous path or searching through command history is tedious. Luckily, cd has an option to go back to the previous working directory – simply use: cd -

July 22, 2025 · 1 min · 66 words · Maxim

Monitor Progress of Data Transfer in Console

Linux provides at least two handy command-line tools to monitor data transfer progress: bar and pv. Both display a one-line progress bar with speed, elapsed or estimated time, and provide customizable formatting. Examples with bar: If data size is unknown: dd if=/dev/zero | bar | dd of=/dev/null 2.3GB at 581.8MB/s elapsed: 0:00:04 If data size is known: dd if=/dev/zero iflag=count_bytes count=10G | bar --size 10G | dd of=/dev/null 1.2GB at 592.8MB/s eta: 0:00:15 11% [===== ] Examples with pv: ...

July 21, 2025 · 1 min · 172 words · Maxim

Interacting with I2C Peripherals from Linux Console

When you need to interact with I2C peripherals from the Linux console, for example during hardware bringup phase, you can use command line utilities available in the i2c-tools package. This is much faster than making changes in Linux kernel drivers, as no recompilation, installation, or reboots are needed. In my case, it was a camera device, and I had to make sure that the camera was available on the I2C bus. ...

July 17, 2025 · 2 min · 355 words · Maxim

You can use POSIX API in Swift on MacOS

Swift on macOS can access POSIX APIs by importing the Darwin module. This gives you access to low-level system calls, file operations, and other Unix functionality. In my case I needed to call openpty() function from Swift application and handle raw file descriptors. import Darwin // Example: Get current working directory let cwd = getcwd(nil, 0) if let path = cwd { print("Current directory: \(String(cString: path))") free(cwd) } // Example: Create a directory (if app is not sandboxed) let result = mkdir("/tmp/testdir", 0o755) if result == 0 { print("Directory created successfully") } else { print("Failed to create directory: \(errno)") }

July 9, 2025 · 1 min · 100 words · Maxim