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.

How to edit Cronjob Email Subject??

Discussion in 'E-mail Discussions' started by CaMer0n, Feb 16, 2007.

  1. CaMer0n

    CaMer0n Well-Known Member

    Joined:
    Nov 8, 2004
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Hi,

    I have a cronjob to back the mysql DB, entered in Cpanel in the following format:

    date=`date -I`; mysqldump -uusername -ppassword db_name | gzip > /home/user/path/to/backup/backup_name_$date.gz

    Problem is, that the notification email puts my password etc in the email subject, which I don't consider to be very secure practise.

    Can someone suggest how I might edit the subject of the email that Cron is sending?
    Can it be done in the Cron command itself?

    Thanks
     
  2. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    18
    Well, you could place your commands into a script, then place the script in the cronjob rather than the command itself...
     
  3. CaMer0n

    CaMer0n Well-Known Member

    Joined:
    Nov 8, 2004
    Messages:
    59
    Likes Received:
    0
    Trophy Points:
    6
    Thanks.
    I'm a real newbie to cron-jobs.
    Could you (or anyone else) paste an example script based on the command above?

    Thanks in advance.
     
  4. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    18
    Scripts generally start with:

    Code:
    #!/bin/sh
    
    Your code goes here
    So, in your case:

    Code:
    #!/bin/sh
    
    date=`date -I`; mysqldump -uusername -ppassword db_name | gzip > /home/user/path/to/backup/backup_name_$date.gz
    That's all one line, of course...

    If you open a text editor such as nano, you can use the -w switch to keep it all on one line:

    nano -w /path/to/script

    Once you've created the script, be sure to make it executible:
    chmod +x /path/to/script

    I think that covers it...
     
Loading...

Share This Page