View previous topic :: View next topic |
Author |
Message |
fraun n00b
Joined: 15 Apr 2020 Posts: 7
|
Posted: Wed May 20, 2020 9:50 am Post subject: Possible permissions problems with scripts from cron/xinit |
|
|
Hi,
I'm not really sure what the problem is and don't know what logs or details to paste...
Example 1: offlineimap
I use a postsynchook to run a bash script in ~/bin. This script runs when I call offlineimap through a terminal, but doesn't run when it's called through cron. Everything else works fine regarding offlineimap through cron and cron is being run for my user. When I create a file using cron, ie touch file, it has the correct permissions.
Example 2: sxhkd
I use sxhkd for window management. When it is started through startup scripts like xprofile or xinitrc I cannot give it bash scripts to run stored in ~/bin. But like with offlineimap, if I start sxhkd through a terminal logged in as a user then it runs any script no problem.
Thanks for any help |
|
Back to top |
|
|
mike155 Advocate
Joined: 17 Sep 2010 Posts: 4438 Location: Frankfurt, Germany
|
Posted: Wed May 20, 2020 10:52 am Post subject: |
|
|
If you run scripts or programs from cron or during system bootup, the environment will be different, especially the PATH variable.
Add the line below to your scripts
Code: | export >"/tmp/env-$(/bin/date +%s).txt" |
and run them from your shell, from cron and during system bootup. Can you see the difference? |
|
Back to top |
|
|
fraun n00b
Joined: 15 Apr 2020 Posts: 7
|
Posted: Wed May 20, 2020 11:29 am Post subject: |
|
|
Ok, I think I'm close to the problem. What you've said makes sense and through some more digging i think some of my problems are that DBUS_SESSION_BUS_ADDRESS isn't being set.
when I look at /tmp/env-$(/bin/date +%s).txt its super short:
Code: |
HOME=/home/fraun
LANG=en_GB.utf8
LOGNAME=fraun
OLDPWD=/home/fraun
PATH=/usr/bin:/bin
PWD=/home/fraun
SHELL=/bin/sh
SHLVL=2
USER=fraun
XDG_RUNTIME_DIR=/run/user/1000
XDG_SESSION_CLASS=background
XDG_SESSION_ID=40
XDG_SESSION_TYPE=unspecified
|
While gives me a much longer output as I'd expect. Not sure if this is how it should be or not...
Edit: Exporting the correct DBUS_SESSION_BUS_ADDRESS in one of my scripts has solved the offlineimap problem. But I'm still not sure if I should be doing something different with exporting my environment. |
|
Back to top |
|
|
|