#!/bin/bash DIR=~/Documents/photos/main/unsorted target=$DIR cd "$DIR" for file in *.JPG do echo "processing file $file" year=$(stat $file | grep -oP "(?<=(Modify:\s)).*?\d{4}") month=$(stat $file | stat $file | grep -oP "(?<=(Modify:\s)).*?\d{4}-\d{2}") if [ ! -d "$target/$year" ]; then mkdir "$target/$year" echo "starting new year: $year" fi if [ ! -d "$target/$year/$month" ]; then mkdir "$target/$year/$month" echo "starting month folder: $month" fi echo "moving file $file" mv "$file" "$target/$year/$month" done
Notes
4/20/2020
Sorting files by folders in linux
12/19/2015
7/22/2015
6/08/2015
1/21/2015
Understanding java.lang.ref.Reference
Going from strongest to weakest, the different levels of reachability reflect the life cycle of an object. They are operationally defined as follows:
- An object is strongly reachable if it can be reached by some thread without traversing any reference objects. A newly-created object is strongly reachable by the thread that created it.
- An object is softly reachable if it is not strongly reachable but can be reached by traversing a soft reference.
- An object is weakly reachable if it is neither strongly nor softly reachable but can be reached by traversing a weak reference. When the weak references to a weakly-reachable object are cleared, the object becomes eligible for finalization.
- An object is phantom reachable if it is neither strongly, softly, nor weakly reachable, it has been finalized, and some phantom reference refers to it.
- Finally, an object is unreachable, and therefore eligible for reclamation, when it is not reachable in any of the above ways.
12/10/2014
Firefox 34 search engine bar: make it stops
New look and feel of the search bar in Firefox 34 makes it hard to use shortcuts. So let's revert it back.
In about:config, toggle the pref browser.search.showOneOffButtons
In about:config, toggle the pref browser.search.showOneOffButtons
11/07/2014
Alternative Way to Daemonize Java Applications on Systemd (CentOS7/RHEL7)
Source: http://ae.koroglu.org/alternative-way-to-daemonize-java-applications-on-systemd-centos7rhel7/
I already explained how to daemonize java applications on SysV-style system in here. Since CentOS7/RHEL7 comes with Systemd which is a system and service manager for Linux we migrate old init script to the new system.
Again we’ll use our best budy Daemonize but this time we gonna compile it from source because although it’s signed as approved on fedora package db, Daemonize is not in EPEL7 repository for now. I’ll not going to details how to compile install etc. but I assume that you installed daemonize into /usr/local/sbin
So we need to create two files /etc/sysconfig/fixtures and /lib/systemd/system/fixtures.service
This 1st file is where we define java releated variables such as user, java path, arguments, log files etc..
2nd file is service file for fixtures where we define systemd releted variables. There are plenty of documents in Freedesktop Systemd wiki, if you want to know more about I advice you to read them. But roughly unit: consist information about a service, a socket, a device etc, service: information about a process controlled and supervised by systemd and install: installation information for the unit
Let’s start and stop the service
if there is something wrong all service files and docker containers insert data into the systemd journal and we can read the journal :)
Checking the service status
Enable a service to be started on bootup
So that’s how it works..
Again we’ll use our best budy Daemonize but this time we gonna compile it from source because although it’s signed as approved on fedora package db, Daemonize is not in EPEL7 repository for now. I’ll not going to details how to compile install etc. but I assume that you installed daemonize into /usr/local/sbin
So we need to create two files /etc/sysconfig/fixtures and /lib/systemd/system/fixtures.service
This 1st file is where we define java releated variables such as user, java path, arguments, log files etc..
1 2 3 4 5 6 7 8 9 10 | # Configz for fixtures service JAVA_USER="pronet" JAVA_STDOUT="/var/log/pronet/fixtures.log" JAVA_STDERR="/var/log/pronet/fixtures-error.log" JAVA_BIN="/usr/java/jdk1.7.0_71/bin/java" JAVA_APPDIR="/opt/pronet/fixtures" ARG1="-Dfile.encoding=UTF-8 -Dproject.properties=/opt/pronet/fixtures/fixtures.properties" ARG2="-Dlog4j.configuration=file:/opt/pronet/fixtures/fixtures-log.properties" ARG3="-jar /opt/pronet/fixtures/fixtures.jar" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | [Unit] Description=Fixtures Service After=syslog.target After=network.target [Service] Type=forking EnvironmentFile=-/etc/sysconfig/fixtures ExecStart=/usr/local/sbin/daemonize -u $JAVA_USER -o $JAVA_STDOUT -e $JAVA_STDERR -c $JAVA_APPDIR $JAVA_BIN $ARG1 $ARG2 $ARG3 ExecStop=/bin/kill -TERM $MAINPID TimeoutSec=300 [Install] WantedBy=multi-user.target |
[root@Srv25 pronet]# systemctl start fixtures [root@Srv25 pronet]# systemctl stop fixtures |
[root@Srv25 pronet]# journalctl -u fixtures.service |
[root@Srv25 pronet]# systemctl status fixtures fixtures.service - Fixtures Service Loaded: loaded (/usr/lib/systemd/system/fixtures.service; disabled) Active: active (running) since Wed 2014-10-29 21:21:49 EET; 13min ago Main PID: 28859 (java) CGroup: /system.slice/fixtures.service └─28859 /usr/java/jdk1.7.0_71/bin/java -Dfile.encoding=UTF-8 -Dproject.properties=/opt/pronet/fixtures/fixtures.properties -Dlog4j.configuration=file:... Oct 29 21:21:49 Srv25 systemd[1]: Started Fixtures Service. |
[root@Srv25 pronet]# systemctl enable fixtures.service ln -s '/usr/lib/systemd/system/fixtures.service' '/etc/systemd/system/multi-user.target.wants/fixtures.service' [root@Srv25 pronet]# |
Subscribe to:
Posts (Atom)