Skip to content

Commit 75923d4

Browse files
committed
Fix cronjobs not setting USER variable
I start ./loop_gdb.sh with a cronjob set in `crontab -e` it runs as a non root linux user. But cron does not set the environment variable USER I could in the `crontab -e` at the top manually do `USER=chiller` but there is a risk I forget this. I tested `whoami` instead of `$USER` and it actually seemed to be set. Also `id` showed the name but I found no flag to only print the name. So from my quick test it seems like `whoami` is more portable than then `$USER` variable. Fixes the following error I got: rm: remove write-protected regular file '/tmp/_ddpp_build_lock.txt.lock'? You can see the missing username in front of the leading _ that is because the $USER expanded to the empty string because the ./loop_gdb.sh was started from cron. Then this file was shared between multiple users and the `mv` command became interactive. Because the underlying `rm` command noticed a permissions change. Could also do a `rm -f` here but the actual issue is that we shared the lock file for multiple users.
1 parent 6dff1ab commit 75923d4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/include/build_lock.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# unlock_build
1313

14-
BUILD_LOCKFILE=/tmp/"$USER"_ddpp_build_lock.txt
14+
BUILD_LOCKFILE=/tmp/"$(whoami)"_ddpp_build_lock.txt
1515

1616
###################
1717
# internal helpers

0 commit comments

Comments
 (0)