Home > other >  How to pass blank parameters to a script called in crontab (linux)
How to pass blank parameters to a script called in crontab (linux)

Time:03-25

I am trying to pass a blank parameter using double quotes "" but it just gets ingnored. 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

Params A and B end up in the correct position in myscript.sh, but D and E end up in param positions 3 and 4 in myscript.sh (instead of positions 4 and 5).

Any ideas please?

Thanks

I don't know what to try from this point.

CodePudding user response:

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'
  • Related