Find the answer to your Linux question:
Results 1 to 3 of 3
hi all, I'm very confused as to why I am getting this error message when I run a cronjob for a backup script I'm working on: Code: mkdir: cannot create ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2011
    Posts
    11

    cronjob output, what does "\r/r" mean?


    hi all,
    I'm very confused as to why I am getting this error message when I run a cronjob for a backup script I'm working on:

    Code:
    mkdir: cannot create directory `/home/erind/socprojects_backups/10_19_2011\r/\r': No such file or directory

    The script leading up to this error is:

    Code:
    # ./SocProjects/cronjobs/weekly_fullbackup.sh
    # Backup script for SOC project files and mysql database, to be executed weekly.
    #################################
    # Assign DTG and Date variables #
    # to $a & $b respectively       #
    #################################
    a=$(date +%T-%d_%m_%Y)
    b=$(date +%m_%d_%Y)
    ########################################
    # Backup Site Directory - files and db #
    ########################################
    ### echo command states the name of the directory being made for the current backup,
    ### where the filesystem/code and database backup copies will go. The mkdir command
    ### actually creates the directory.
    echo "mkdir /home/erind/socprojects_backups/".$b
    mkdir /home/erind/socprojects_backups/$b/

    I'm really confused because I wrote this script modeled after another backup script that does not have this problem. I don't get why the output is showing me "\r/\r"

    Any help appreciated!

  2. #2
    Linux Engineer Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    773
    $b does probably contain a \r (alias carriage return, alias linefeed, alias newline), coming from "$(date +%m_%d_%Y)"

    when you execute the date command directly, the output should be something like:
    Code:
    $date +%m_%d_%Y
    10_19_2011
    $
    but you expect it to be:

    Code:
    $date +%m_%d_%Y
    10_19_2011$

  3. #3
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Did you make that backup script in Windows, by chance? Run this to view special characters in the file:
    Code:
    cat -v ./SocProjects/cronjobs/weekly_fullbackup.sh
    If so, you'll see ^M at the end of each line.

    Try dos2unix, if that is indeed your problem.

  4. $spacer_open
    $spacer_close

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •