Update cronjobs.sh
set to work also if in different folder structure and improved logging
This commit is contained in:
parent
ac82e9b5cc
commit
dd08482038
33
cronjobs.sh
33
cronjobs.sh
|
|
@ -1,21 +1,26 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Starting Script $0"
|
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
# Get the current date and time in a specific format
|
PHP_BIN="php"
|
||||||
formatted_time=$(date +"%Y-%m-%d %H:%M:%S")
|
LOG_FILE="$BASE_DIR/cron.log"
|
||||||
|
|
||||||
# Echo the formatted time
|
echo "=========================================" >> "$LOG_FILE"
|
||||||
echo "Current time: $formatted_time"
|
echo "CRON START $(date '+%Y-%m-%d %H:%M:%S')" >> "$LOG_FILE"
|
||||||
|
echo "BASE_DIR: $BASE_DIR" >> "$LOG_FILE"
|
||||||
|
|
||||||
|
cd "$BASE_DIR" || { echo "cd failed: $BASE_DIR" >> "$LOG_FILE"; exit 1; }
|
||||||
|
|
||||||
cd domains
|
start_ts=$(date +%s)
|
||||||
cd zefix.silias.ch
|
|
||||||
cd public_html
|
|
||||||
/usr/bin/php taskExecuter.php
|
|
||||||
echo "Script is Ending $0"
|
|
||||||
|
|
||||||
# Get the current date and time in a specific format
|
$PHP_BIN "$BASE_DIR/taskExecuter.php" >> "$LOG_FILE" 2>&1
|
||||||
formatted_time=$(date +"%Y-%m-%d %H:%M:%S")
|
status=$?
|
||||||
|
|
||||||
# Echo the formatted time
|
end_ts=$(date +%s)
|
||||||
echo "Current time: $formatted_time"
|
duration=$((end_ts - start_ts))
|
||||||
|
|
||||||
|
echo "Exit code: $status" >> "$LOG_FILE"
|
||||||
|
echo "Duration: ${duration}s" >> "$LOG_FILE"
|
||||||
|
echo "CRON END $(date '+%Y-%m-%d %H:%M:%S')" >> "$LOG_FILE"
|
||||||
|
echo "" >> "$LOG_FILE"
|
||||||
|
|
||||||
|
exit $status
|
||||||
Loading…
Reference in New Issue