How to Execute a Command Whenever a File Changes

How to execute a command whenever a file changes?

while inotifywait -e close_write myfile.py; do ./myfile.py; done or

inotifywait -q -m -e close_write myfile.py | while read -r filename event; do ./myfile.py # or “./$filename” done The first snippet is simpler, but it has a significant downside: it will miss changes performed while inotifywait isn’t running (in particular while myfile is running). The second snippet doesn’t have this defect.

Tags: cli, linux, snipped

[Read more]

Kill Processes Older Than Giventime

Kill processes older than $giventime

On out ssh jumpserver we sometimes have ssh processes that dont want to die after they are used. over the time they cloak the system.

i found out that the GNU Killall just do the job for me.

“killall –older-than 1d ssh” would do the trick 😉

this kills all ssh processes thats older than 1 day

Tags: cli, linux

[Read more]

Little Docker Swarm Walkthru

Little Docker Swarm walkthru

I’ll try to setup a two node docker swarm. quiet easy and done in 10 minutes. i used 2 ubuntu 16.4 64 bit vm’s.

Hostname External IP Internal IP scw-5fd012 212.47.239.153 10.2.37.217 scw-095a80 212.47.240.218 10.2.222.81 i also assume u installed docker.

you need to decide which one will be the manager.

i choose scw-5fd012. on that node i enter a

root@scw-5fd012:~# docker swarm init –advertise-addr 10.2.37.217 Swarm initialized: current node (5lpm87bmugszxrx920k2zmx6k) is now a manager.

[Read more]

Mount an Iscsi Target With Linux Debian

Mount an iSCSI Target with Linux (Debian)

now part two. we have to mount the LUN’s on a other computer to test it.

apt-get install open-iscsi

edit the file /etc/iscsi/iscsid.conf, set node.startup = automatic

then we restart the whole thing

service open-iscsi restart

we look if we can see something..

iscsiadm -m discovery -t sendtargets -p SERVERIP

we note the ip and the targetname… then we try to login.

iscsiadm –mode node –targetname TARGETNAME –portal SERVERIP:3260 –login

[Read more]

Postgresql Show Tables Show Databases Show Columns Describe Table

Postgresql: show tables, show databases, show columns, describe table

PostgreSQL is one of the best database engines for an average web project and many who moves to psql from mysql (for example) often ask the following questions: what is the analog of “show tables” in postgres? or how can I get the list of databases in postgres like “show databases” in mysql? The answers are short:

mysql: SHOW TABLES postgresql: \d postgresql: SELECT table_name FROM information_schema.tables WHERE table_schema = ‘public’;

[Read more]