'How to pass blank parameters to a script called in crontab (Linux)
I am trying to pass a blank parameter using double quotes, ""
, but it just gets ignored. All parameters after the blank parameter end up in the wrong position in the called script.
My crontab entry looks like:
* * * * * myscript.sh A B "" C D
Parameters A and B end up in the correct position in myscript.sh, but D and E end up in parameter positions 3 and 4 in myscript.sh (instead of positions 4 and 5).
How can I fix this?
Solution 1:[1]
I would suggest (without having tested it) the following:
* * * * * /usr/bin/env bash -c 'myscript.sh A B "" C D'
or alternatively just
* * * * * bash -c 'myscript.sh A B "" C D'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |