1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Create a cron job to collect and PM stats

Discussion in 'XenForo Questions and Support' started by Andy.N, Aug 29, 2012.

  1. Andy.N

    Andy.N Well-Known Member

    I would like to create a cron job to run a sql query to collect post/threads/like in a certain forum and PM it to a few people. The cron job is scheduled for every Sunday.

    Does anyone know how do I go about it?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Tools -> Cron Entries -> Create New Cron Entry

    Then you need to point it to a class and method for which you will need to create a PHP file.
  3. Andy.N

    Andy.N Well-Known Member

    Way over my head, Jake.
    Any examples to get started?

    I was googling to help myself and it looks like just writing a script on the server and create a cron job would be easier?
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If you look at the other crons then there are good code examples to follow.
  5. Andy.N

    Andy.N Well-Known Member

    Hi Jake,
    Here is the very simple piece of code I found online that does the queries and email SQL result as CSV attachment.

    Would really appreciate if you can help with the steps of how to create a cron job that will run every Sunday.
    Thanks very much.
  6. Andy.N

    Andy.N Well-Known Member

    The sample code above provides everything I need. I set up a cronjob and get it working they way I want.
    Thanks for your help, Jake.
    Jake Bunce likes this.
  7. ProCom

    ProCom Active Member

    Hey @Andy.N can you help the rest of us newbies and write up what you did?

    Let's say I want to run a VERY simple command every night at 9:pm EST: cp file1.zip file2.zip

    How would I set this up to run via xF admin panel?

    The "Cron Callback:" confuses the heck out of me.

    @Andy.N you mentioned the code provided everything you needed, but where did you put the code and how did you setup the cron?


Share This Page