From 6702834204dd2d1f19b9c9b5ae571f64e4c640dd Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Tue, 19 Jun 2018 21:32:30 -0400 Subject: [PATCH] Update launch scripts to sort storage by input/output and year --- Core/Core.csproj | 1 + Core/Remote/piscal_launcher.sh | 10 +++++++++- Core/Remote/piscal_manager.sh | 10 +++++----- Core/Remote/subdir_year.sh | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 Core/Remote/subdir_year.sh diff --git a/Core/Core.csproj b/Core/Core.csproj index 6a1a1eb..e4a676e 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -164,6 +164,7 @@ PreserveNewest + diff --git a/Core/Remote/piscal_launcher.sh b/Core/Remote/piscal_launcher.sh index 9b560f5..368c00b 100644 --- a/Core/Remote/piscal_launcher.sh +++ b/Core/Remote/piscal_launcher.sh @@ -98,7 +98,15 @@ popd >> /dev/null if [ -z "$suppress_storage_copy" ]; then cp "$output_directory_touser"/* "$storage_directory"/output/ 2>/dev/null cp "$output_directory_nottouser"/* "$storage_directory"/output/ 2>/dev/null - cp "$cleaned_input_directory"/* "$storage_directory"/output/ 2>/dev/null + cp "$cleaned_input_directory"/* "$storage_directory"/input/ 2>/dev/null + + mv_script=$base_directory/subdir_year.sh + pushd "$storage_directory"/output >> /dev/null + "$mv_script" + popd >> /dev/null + pushd "$storage_directory"/input >> /dev/null + "$mv_script" + popd >> /dev/null fi # notify given url of completion diff --git a/Core/Remote/piscal_manager.sh b/Core/Remote/piscal_manager.sh index 7452630..2a7feb5 100644 --- a/Core/Remote/piscal_manager.sh +++ b/Core/Remote/piscal_manager.sh @@ -90,9 +90,9 @@ pid_path="$working_directory/$pid_filename" ## Process task if [ "$task" = "launch" ]; then # verify process isn't running yet - pid=$(head -n 1 $pid_path) + pid=$(head -n 1 $pid_path 2>/dev/null) # if the pid exists, check the process status using ps - if ps -p $pid > /dev/null; then + if ps -p $pid &>/dev/null; then # if it is in ps, then it's still running echo still running exit 1 @@ -127,7 +127,7 @@ elif [ "$task" = "get_status" ] || [ "$task" = "get_status_cleaned_input" ]; the exit fi - pid=$(head -n 1 $pid_path) + pid=$(head -n 1 $pid_path 2>/dev/null) # if the pid exists, check the process status using ps if ps -p $pid > /dev/null; then # if it is in ps, then it's still running @@ -161,7 +161,7 @@ elif [ "$task" = "get_status" ] || [ "$task" = "get_status_cleaned_input" ]; the fi fi elif [ "$task" = "cleanup" ]; then - pid=$(head -n 1 $pid_path) + pid=$(head -n 1 $pid_path 2>/dev/null) # if the pid exists, check the process status using ps if ps -p $pid > /dev/null; then # if it is in ps, then it's still running @@ -176,7 +176,7 @@ elif [ "$task" = "kill" ]; then exit 1 fi - pid=$(head -n 1 $pid_path) + pid=$(head -n 1 $pid_path 2>/dev/null) # if the pid exists, check the process status using ps if ps -p $pid > /dev/null; then # if it is in ps, then it's still running diff --git a/Core/Remote/subdir_year.sh b/Core/Remote/subdir_year.sh new file mode 100644 index 0000000..fb16fba --- /dev/null +++ b/Core/Remote/subdir_year.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +for file in *; do + ## Skip unless this is a file + if [ -f "$file" ]; then + ## get the first four characters from filename, aka the year + target="${file:0:4}" + ## Create the target directory if it doesn't exist + [ -d "$target" ] || mkdir "$target" 2>/dev/null + ## Move the current file + mv "$file" "$target" 2>/dev/null + fi +done +