-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttendManip.sh
25 lines (18 loc) · 1.1 KB
/
AttendManip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
user=$(whoami)
loc_file=$(locate AttendManip.sh)
nl=$(cat /etc/crontab | grep -c 'AttendManip.sh')
if [[ $nl -eq 0 ]]
then
echo "0 6 * * * $user "\"\\\"$loc_file\\\"\" | sudo tee -a /etc/crontab >/dev/null 2>&1
fi
Date=$(date -I -d "-1 day")
sudo touch /home/ArmyGeneral/attendance_record.txt
echo "$Date:" | sudo tee -a /home/ArmyGeneral/attendance_record.txt >/dev/null 2>&1
grep -i "$Date.* Army" attendance.log | awk '{if ( $3 == "YES" ) print "\t"$2}' | sudo tee -a /home/ArmyGeneral/attendance_record.txt >/dev/null 2>&1
sudo touch /home/NavyMarshal/attendance_record.txt
echo "$Date:" | sudo tee -a /home/NavyMarshal/attendance_record.txt >/dev/null 2>&1
grep -i "$Date.* Navy" attendance.log | awk '{if ( $3 == "YES" ) print "\t"$2}' | sudo tee -a /home/NavyMarshal/attendance_record.txt >/dev/null 2>&1
sudo touch /home/AirForceChief/attendance_record.txt
echo "$Date:" | sudo tee -a /home/AirForceChief/attendance_record.txt >/dev/null 2>&1
grep -i "$Date.* AirForce" attendance.log | awk '{if ( $3 == "YES" ) print "\t"$2}' | sudo tee -a /home/AirForceChief/attendance_record.txt >/dev/null 2>&1