-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.bash
More file actions
38 lines (30 loc) · 1.07 KB
/
utils.bash
File metadata and controls
38 lines (30 loc) · 1.07 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
# Reference: https://stackoverflow.com/questions/878600/how-to-create-a-cron-job-using-bash-automatically-without-the-interactive-editor
function __register_cronjob() {
CRONJOB="$1"
crontab -l > current_cronjobs.txt
if grep -F "$CRONJOB" current_cronjobs.txt
then
echo "Cronjob is already registered."
rm current_cronjobs.txt
else
echo "$CRONJOB" >> current_cronjobs.txt
crontab current_cronjobs.txt
echo "Added cronjob: $CRONJOB successfully!"
# rm because the current cron jobs get written to a local file in the invoking directory
rm current_cronjobs.txt
fi
}
# Sorry for duplication, but I'm afraid I might break the project :(
# Tomorrow's the deadline!
function __get_file_fullpath() {
BASENAME=$( basename -- "$1" )
WORKING_DIRECTORY=$( pwd )
FULL_PATH="${WORKING_DIRECTORY}/${BASENAME}"
echo "$FULL_PATH"
}
function __get_script_fullpath() {
BASENAME=$( basename -- "$0" )
WORKING_DIRECTORY=$( pwd )
FULL_PATH="${WORKING_DIRECTORY}/${BASENAME}"
echo "$FULL_PATH"
}