Stepping back a bit, there are 2 points to be made here:
1) This is a "dash" vs. "bash" thing. bash takes either = or ==, while dash only likes =.
The point here is that while switching to = (rather than ==) is technically correct, it belies the fact that you probably want your script to run with bash anyway and the real problem is that (without putting #!/bin/bash), cron runs it with dash.
2) When working with cron, you really need to set things up so that you can see the error messages. Observe:
If you had seen the above error messages, you would have easily worked out what the problem was.
1) This is a "dash" vs. "bash" thing. bash takes either = or ==, while dash only likes =.
The point here is that while switching to = (rather than ==) is technically correct, it belies the fact that you probably want your script to run with bash anyway and the real problem is that (without putting #!/bin/bash), cron runs it with dash.
2) When working with cron, you really need to set things up so that you can see the error messages. Observe:
Code:
$ dash -c '[ foo == foo ] && echo OK'sh: 1: [: foo: unexpected operator$
Statistics: Posted by BigRedMailbox — Fri Nov 22, 2024 9:12 am