The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

& is not allowed in crons?

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

  1. nerod

    nerod Member

    Joined:
    Feb 4, 2011
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    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
    Staff Member

    Joined:
    Feb 25, 2010
    Messages:
    1,842
    Likes Received:
    18
    Trophy Points:
    38
    Location:
    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:

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

    Code:
    # 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.
     
Loading...

Share This Page