It seems to me that cron and rc.d scripts ignore profile files.
On my servers and desktop I use Apache with RVM and Passenger and Rails. Apache is installed from ports and the rest is installed with my user into the home. This setup requires several lines to be added to the .bashrc and .bash_profile as I use bash.
When I run /usr/local/etc/rc.d/apache22 restart as root from command line then everything works fine.
When I reboot the system apache displays error 500 pages because it cannot see env variables and so required to run RVM properly. It can be fixed by simply restarting apache. I think that the normal user's .bash_profile only runs when I run /usr/local/etc/rc.d/apache22 restart from command line as root but not when the system runs it.
(Apache runs Passenger and RVM with my user this is why it has to be mine .bash_profile file.)
Another related thing is that I have these lines in /etc/profile:
There is shell script in my non-root home folder has to be run several times per day. (Spamassassin autowhitelist).
The result ran by cron differs from the result ran by command line. The difference is that grep cannot see characters like "ü" from cron. It seems to me that cron doesn't use /etc/profile.
How can I solve these issues in an elegant way? I would like to make cron and rc.d scripts work exactly same ran either by system or by the user if this isn't a security risk.
A side note that I tend to delete /.cshrc and /.profile after installing FreeBSD because I don't like to have files in /.
On my servers and desktop I use Apache with RVM and Passenger and Rails. Apache is installed from ports and the rest is installed with my user into the home. This setup requires several lines to be added to the .bashrc and .bash_profile as I use bash.
When I run /usr/local/etc/rc.d/apache22 restart as root from command line then everything works fine.
When I reboot the system apache displays error 500 pages because it cannot see env variables and so required to run RVM properly. It can be fixed by simply restarting apache. I think that the normal user's .bash_profile only runs when I run /usr/local/etc/rc.d/apache22 restart from command line as root but not when the system runs it.
(Apache runs Passenger and RVM with my user this is why it has to be mine .bash_profile file.)
Another related thing is that I have these lines in /etc/profile:
Code:
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
There is shell script in my non-root home folder has to be run several times per day. (Spamassassin autowhitelist).
The result ran by cron differs from the result ran by command line. The difference is that grep cannot see characters like "ü" from cron. It seems to me that cron doesn't use /etc/profile.
How can I solve these issues in an elegant way? I would like to make cron and rc.d scripts work exactly same ran either by system or by the user if this isn't a security risk.
A side note that I tend to delete /.cshrc and /.profile after installing FreeBSD because I don't like to have files in /.