Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

& is not allowed in crons?

Discussion in 'General Discussion' started by nerod, Mar 6, 2011.

  1. nerod

    nerod Member

    Feb 4, 2011
    Likes Received:
    Trophy Points:
    For the first time in years, one of my crons failed. I changed the mysql password yesterday (part of the cron), which seems like it was likely the cause (the error was barking about the characters after & -- which was a character in the password).

    Curious why cpanel allows the & symbol to be entered as a character if it has the possibility to break things?

    Today is not my day.... happened with ( as well!
    #1 nerod, Mar 6, 2011
    Last edited: Mar 6, 2011
  2. cPanelJared

    cPanelJared Technical Analyst

    Feb 25, 2010
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    The ampersand (&) is used on the Linux command line to separate commands, and that is how it is being interpreted. It is a legal character, but if it is in the middle of the password, everything after the ampersand will be considered to be a new command.

    You can try escaping the ampersand by placing a backslash (\) immediately in front of it.

    To explain further how the ampersand is treated by the shell (and by cron), consider the following examples:

    # date & w
    This tells the shell "Execute the date command and then execute the w command." The following example:

    # date && w
    tells the shell "Execute the date command and if and only if it completes successfully, execute the w command. If the first command returns an exit code other than 0, the next command will not be executed.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice