Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

mySQL table to Email.. Cron? on blacknight

  • 27-05-2010 4:44pm
    #1
    Registered Users, Registered Users 2 Posts: 771 ✭✭✭


    ive got a small mySQL table and i want to set it up so that the contents are emailed to my client daily.. can this be done via a cron job? and if so can anyone help with the 'command' i need to enter..

    It's a Blacknight Linux Shared hosting account

    Many thanks


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Moved from development.


  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    I searched for cron email mysql.
    This looked interesting: http://www.tamba2.org.uk/wordpress/cron/
    (it doesn't matter that you are not using WordPress)

    It looks like mysqldump can export individual tables.

    Note: mysqldump does not produce a nice readable text file.
    If you want a readable one you'll need to write code to query the table, write the data in a nice format and then email it.
    I suggest you write a script to produce a web page, then adapt that for emailing.


  • Closed Accounts Posts: 19,080 ✭✭✭✭Random


    did you try any of these methods out whiteshadow? did you have any luck? which did you find the best?

    thanks


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭oeb


    Hey there, I have done this a few times in the past.

    There are a couple of ways of doing it. If it's a big table I would write a perl script to do it. You would need to read up on Sending attachments via perl and the mysqldump command. You can then set a cron job to execute the script on a regular basis. Blacknight have instructions on how to set up a cron job here or if you have a VPS or dedicated server you can probably set them via plesk or by using SSH to connect to your server and editing your crontab yourself.

    The other method, only really suitable for smaller tables would be to just use PHP to extract the content and email it on. How you execute a PHP (non-shell) script with a cron job is by faking a browser request. This can be done by using the wonderful program wget (Which should be available on all of the blacknight servers)


  • Registered Users, Registered Users 2 Posts: 1,862 ✭✭✭flamegrill


    You can use curl or wget to do this. As Oeb suggested.

    e.g. /usr/bin/curl /dev/null http://www.mydomain.com/path/to/php/file

    This will execute the php script of your choosing which can get the table contents, format them nicely and send them via e-mail to your customer.

    Paul


  • Advertisement
Advertisement