LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   cron bash script troubles (https://www.linuxquestions.org/questions/slackware-14/cron-bash-script-troubles-310891/)

zzyzx 04-07-2005 06:12 PM

cron bash script troubles
 
Having a trouble understanding the problem with the following command:

Code:

comm -23  <(grep 'sshd.*Connection from\|Invalid' /var/log/sshd.log) $WKLOG > $TMPLOG
It runs fine from the command line (w/ filenames not variables) and when I execute the script myself, ./<script>, but when it runs from cron it chokes on this command. The stderr output is:

line 11: syntax error near unexpected token `('
line 11: comm -23 <(grep 'sshd.*Connection from\|Invalid' /var/log/sshd.log) $WKLOG > $TMPLOG

Any idea what's causing the change from command line to cron? Both are running as root.

Thanks for any help!

keefaz 04-08-2005 07:37 AM

Are you sure there is not space between < and ( in crontab ?

zzyzx 04-08-2005 12:20 PM

No space. Actually this is just part of the script, which I can run fine outside of cron. My crontab entry just runs the script:

*/10 * * * * /root/cronscripts/sshd_access.sh 2> /root/log/errorsshd

Tthe only difference is that it doesn't like that line. Does cron run through a different shell? I'm new to bash and Linux for that matter and I'm totally at a loss.

zzyzx 04-12-2005 12:27 PM

:newbie:

Ok, I found the problem and it is embarrassing. The script was missing the magic line #!/bin/bash. <Hang head in shame>I'm such a newb</hang head in shame>

Anyway, happy days, my script runs on cron. And lesson learned: the magic line is necessary. Although, I'm still wondering what shell crond uses by default. Anyone know?


All times are GMT -5. The time now is 07:25 AM.