瀏覽代碼

added a script that adds files after the computer has been started

master
Wouter Horlings 6 年之前
父節點
當前提交
b40f30fd5b
共有 4 個檔案被更改,包括 47 行新增12 行删除
  1. +12
    -0
      createfile.py
  2. +9
    -0
      systemd_timer_files/pythoncreatelog.service
  3. +9
    -0
      systemd_timer_files/pythoncreatelog.timer
  4. +17
    -12
      systemd_timer_files/settimer.sh

+ 12
- 0
createfile.py 查看文件

@@ -0,0 +1,12 @@
from datetime import date

def createfile():
filenames = ["1Start","2Middle","3End"]
todaystr = date.today().strftime("%y%m%d")
if date.today().weekday() < 5:
for filename in filenames:
with open("journal/"+todaystr+"_"+filename,"w") as fh:
pass

if __name__ == '__main__':
createfile()

+ 9
- 0
systemd_timer_files/pythoncreatelog.service 查看文件

@@ -0,0 +1,9 @@
[Unit]
Description="Executes the script that creates the log files needed for today"

[Service]
WorkingDirectory=[[path_to_repo]]
ExecStart=[[path_to_repo]]/.venv/bin/python3 [[path_to_repo]]/createfile.py

[Install]
WantedBy=default.target

+ 9
- 0
systemd_timer_files/pythoncreatelog.timer 查看文件

@@ -0,0 +1,9 @@
[Unit]
Description="Create the logfiles of today"

[Timer]
OnBootSec=1min
Unit=pythoncreatelog.service

[Install]
WantedBy=default.target

+ 17
- 12
systemd_timer_files/settimer.sh 查看文件

@@ -10,6 +10,20 @@ replace_and_move() {
echo "$1 script placed at $OUTDIR"
}

setfile() {
TIMERNAME="$1.timer"
SERVICENAME="$1.service"
replace_and_move $TIMERNAME $MAPPATH
replace_and_move $SERVICENAME $MAPPATH
echo "Reload systemd deamon"
`systemctl --user daemon-reload`
echo "Enable $TIMERNAME for systemd"
`systemctl --user enable $TIMERNAME`
echo "Start $TIMERNAME for systemd"
`systemctl --user start $TIMERNAME`
}


###################
# START OF SCRIPT #
###################
@@ -36,20 +50,11 @@ else
exit
fi

FILENAME="pythontaskcheck"
FOLDERNAME="systemd_timer_files"
MAPPATH="$GIT_DIR/$FOLDERNAME/"
TIMERNAME="$FILENAME.timer"
SERVICENAME="$FILENAME.service"
replace_and_move $TIMERNAME $MAPPATH
replace_and_move $SERVICENAME $MAPPATH

echo "Reload systemd deamon"
`systemctl --user daemon-reload`
echo "Enable $TIMERNAME for systemd"
`systemctl --user enable $TIMERNAME`
echo "Start $TIMERNAME for systemd"
`systemctl --user start $TIMERNAME`
setfile "pythontaskcheck"
setfile "pythoncreatelog"






Loading…
取消
儲存