question on crond job
I have some question ask regarding to cron,
Code:
*/5 * * * * ( cd /etc/Testing; /etc/Testing/scripts.pl) - What is the purpose of using bracket () - why use */5 - why access to the folder twice? ( cd /etc/Testing; /etc/Testing/scripts.pl) Anyone can help? thanks |
I hope my memory isn't faulty here...
Using the () groups the commands so that cron sees them as the command part of the line. They will run in the one sub-shell. */5 in your example means every 5 minutes. You shouldn't need to access the folder twice, the following should work: Code:
*/5 * * * * ( cd /etc/Testing; ./scripts.pl) Code:
*/5 * * * * /etc/Testing/scripts.pl |
Thanks gilead
By the way, what do you mean by Code:
Using the () groups the commands so that cron sees them as the command part of the line. They will run in the one sub-shell. I agree with you for the below, Code:
*/5 * * * * /etc/Testing/scripts.pl |
The parenthesis prevents cron from launching a separate subshell for each part: so that the script sees the cd. Some scripts may get a configuration file from their working directory, hence the need for the cd.
|
Quote:
P.S. Thanks to Matir for clarifying what was happening. |
Duplicate access is needed to prevent abuse. If changing to /etc/Testing/ fails we don't want to run scripts.pl in / .
|
Quote:
|
Well, it will try to run /etc/Testing/scripts.pl (with no luck), rather than ./scripts.pl in crond's working dir, that's what I meant. Surely, && is also an option, but if crond job works, I guess it won't be touched.
|
All times are GMT -5. The time now is 02:10 AM. |