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!

How to edit Cronjob Email Subject??

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

  1. CaMer0n

    CaMer0n Well-Known Member

    Joined:
    Nov 8, 2004
    Messages:
    57
    Likes Received:
    0
    Trophy Points:
    156
    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
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    168
    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:
    57
    Likes Received:
    0
    Trophy Points:
    156
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Lyttek

    Lyttek Well-Known Member

    Joined:
    Jan 2, 2004
    Messages:
    770
    Likes Received:
    3
    Trophy Points:
    168
    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

  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