Find the answer to your Linux question:
Results 1 to 7 of 7
Hello I'm new in linux and want to make cron job for php page Every day at 12 am how can i do that?...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    11

    Exclamation cron job

    Hello
    I'm new in linux and want to make cron job for php page
    Every day at 12 am how can i do that?

  2. #2
    Linux Guru
    Join Date
    May 2011
    Posts
    1,813
    not sure what you mean about the php part, but as to cron, something like this would work:

    Code:
    0 0 * * * /tmp/my_php_script.sh > /tmp/cronjob.log 2>&1
    you'd enter the above example code into the STDIN of the following command
    Code:
    crontab -e
    When you're done editing the file, use the key sequence :wq to save the file and get out. When you're done, use this to check your work:
    Code:
    crontab -l
    Make sure crond is running (ps auxww|grep crond), then after midnite, check for the output of the script in /tmp/cronjob.log. In order to test that it is working, make the cronjob run every minute or something. see more on setting cron times with:
    Code:
    man 5 crontab
    You can also check crond's log, /var/log/cron, for help in seeing what cron is doing.

    If you give more details on the php part, i'm sure someone here can help you w/that.

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    11
    cron already installed but i don't know how to run php script

  4. #4
    Linux Guru
    Join Date
    May 2011
    Posts
    1,813
    ah, so you mean you want to run a php script that is being hosted on a website?

    how about:
    Code:
    wget -O test-output.php http://myserver/myscript.php
    is that what you mean?

  5. #5
    Just Joined!
    Join Date
    Oct 2009
    Posts
    11
    yes i have php script to send email and i want to run it every Friday at midnight

  6. #6
    Linux Guru
    Join Date
    May 2011
    Posts
    1,813
    but i assume the script is run via a webpage hosted on a webserver, yes? How do you run and test it yourself?

    does it require any user input at the page, and then the click of a button, for example? If so, then you'll need to do some modifying of the php script to make it run in an automated fashion (either by hard-coding variables or making the script accept parameters that you can pass via as query string variables to it in the URL).

    If it doesn't require any input, then the previous wget command should have worked.

  7. #7
    Just Joined!
    Join Date
    Oct 2009
    Posts
    11
    thanks for your reply
    I used this command and it work good

    Code:
    30 5 * * * wget url/mail.php

Posting Permissions

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