Watch, Read, Listen

  • AWS – Update massively metadata using boto (python) on multiple S3 objects

    A simple script that allows you to update massively Content-Type for files on an S3 bucket. This script is able to: Browse recursively a bucket Perform action only on files matching specific prefix Auto-detect type of file depending on its extension Obviously, you can add any extension you want to the function update_md to handle…

  • Apache – Proxy some URLs to another server

    In Apache, if you want to forward some requests matching a regex to another server, you can use the rule ProxyPassMatch. Here is an example that is matching URL like: /admin/anything /list/any number/info /manage/any number and redirect it to https://my-hidden-domain.com:26000 ProxyPreserveHost On ProxyRequests Off ProxyPassMatch ^/(admin/.*@.*|list/[0-9]*/info|manage/[0-9]*)$ https://my-hidden-domain.com:26000/$1 You can then define any rule you want…

  • Python – Browse directory and push on S3 (with regex)

    A simple script that can browse a directory, and upload to S3 some files matching a regex. The file will be uploaded by respecting the path you have in local. #!/usr/bin/env python # -*- coding: utf-8 -*- import os, re import boto from boto.s3.connection import S3Connection from boto.s3.key import Key # Variables AWS_ACCESS_KEY_ID = ‘YOUR_AWS_ACCESS_KEY_ID’…

  • Clear cache memory on Linux Systems

    Sometimes, you can see that memory is not correctly released once used and some caching can remain. You can see that by using the free command: # free -m total used free shared buffers cached Mem: 64458 53397 11060 0 1550 49163 -/+ buffers/cache: 2683 61774 Swap: 9998 35 9963 At this time, you can so…

  • Change OVH linux kernel to a standard one

    OVH servers come with a custom kernel provided by OVH. This kernel is compiled with a lots of functions deactivated like: Virtualization components Modules support … If you need those features, you will probably need to install a standard kernel not provided by OVH. For that, just follow the instructions below. Install a standard linux…

  • Move files with a specific extension older than x days

    Need to move or remove a list of files with a particular extension, a particular filename pattern and/or not changed since a specific date? This can be done by combining an action to perform with the result of a find command. Moving files called “FILES*.csv” with a modification date older than 10 days: find /old/directory/ -name…

  • Restrict access by IP on specific page with HAProxy

    Most of time, we are setting only one (or some) IP to be allowed to access to some pages or services. But it can also be necessary sometimes to restrict access of an URL only for one IP (if you are getting some attacks from a hacker for example on some webservice). You can do that restriction much…

  • Rsyslog stops working after logrotate

    You are using an RSyslog mechanism to send your logs to a centralized server, but as soon as the logrotate is executed on the server, no log is sent anymore? I will explain here why this can happen and how to fix it properly. In logrotate, when rotation is happening the old file is renamed…

  • NPM – Warning “root” does not have permission to access the dev dir

    If you want to install some packages using npm and you are getting this kind of error “Warning “root” does not have permission to access the dev dir“, that means that system is trying to compile some native libraries with a wrong user and so lead to an unability to gain access on certain directories. To…

  • Using strace with multiples PIDs

    For debugging purposes, it’s sometimes necessary to debug multiples PIDs at a same time with strace tool. I will take a simple example: PHP-FPM. PHP-FPM is creating several processes depending on its needs, and if you want to perform debugging on it, you can’t easily know what each process is doing. In order to get the results…