LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron Daemon questions (https://www.linuxquestions.org/questions/linux-newbie-8/cron-daemon-questions-4175474115/)

arashi256 08-21-2013 04:36 AM

Cron Daemon questions
 
Hi,

I'm having some problems getting crond to restart my application server. This application server relies on two environment variables exported from /etc/profile. Does crond have access to these environment variables or do I have to define them in the crontab?
Also, I've noticed that a "ps -elf | grep crond" sometimes shows several running crond processes. Does crond spawn child processes for each task it has to perform?

Thanks for any information.

Habitual 08-21-2013 07:59 AM

Quote:

Originally Posted by arashi256 (Post 5012986)
Hi,

I'm having some problems getting crond to restart my application server. This application server relies on two environment variables exported from /etc/profile. Does crond have access to these environment variables or do I have to define them in the crontab?

I usually declare any needed variables in a script and then use that script in a cron.

I believe you can do something like
Code:

env_var1=
env_var2=
00 4 * * * /path/to/your/start_application/binary

or even
Code:

* * * * * export env_var1=x ; export env_var2=y ;  sleep 5s && echo "yo"
and yet, this too may work
Code:

0 5 * * *  ./etc/profile ; /path/to/command/to/run
References:
http://stackoverflow.com/questions/2...ontab-will-use

Others may contribute something I missed (early, no coffee, too much coffee).

Please let us know.

YankeePride13 08-21-2013 09:28 AM

You should put it in a script that way you can also examine the output from the system call to restart your application server and you can then see what the problem.

The variables you need can be set via the script as well.


All times are GMT -5. The time now is 02:14 AM.