+ Reply to Thread
Results 1 to 10 of 10

Thread: Cron job to run once a day is not working.

  1. #1
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Cron job to run once a day is not working.

    I created a cron job to delete all files in a temperory directory once a day at 13:00. But it is not working. Since I don't have any experience with cron jobs, there can be mistake. Please tell me what mistake I have done.
    This is the format :-
    (MINUTE HOUR DAY MONTH WEEKDAY COMMAND ACTIONS)
    (00 13 * * * rm-R/home/bhupendr/public_html/temp/*)
    I am on starka with free hosting plan. If it has anything to do with it.
    Liked this? Click on the icon on the bottom of post to make me .

  2. #2
    zapzack is offline x10 Elder zapzack is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    606

    Re: Cron job to run once a day is not working.

    Quote Originally Posted by bhupendra2895 View Post
    I created a cron job to delete all files in a temperory directory once a day at 13:00. But it is not working. Since I don't have any experience with cron jobs, there can be mistake. Please tell me what mistake I have done.
    This is the format :-
    (MINUTE HOUR DAY MONTH WEEKDAY COMMAND ACTIONS)
    (00 13 * * * rm-R/home/bhupendr/public_html/temp/*)
    I am on starka with free hosting plan. If it has anything to do with it.
    change the command to
    Code:
    find /home/bhupendr/public_html/temp -exec rm -f {} \;

  3. #3
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Cron job to run once a day is not working.

    How, exactly, is it not working? Is nothing deleted? Are some things not deleted? Are you getting any e-mailed output from the command?

    Also try the command: rm -Rf /home/bhupendr/public_html/temp/*. The -f is to force deletion without asking for user input. Note also the space between the options and the path.
    Last edited by misson; 06-18-2010 at 05:30 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  4. #4
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: Cron job to run once a day is not working.

    shell commands work on cron jobs on x10?

  5. #5
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Cron job to run once a day is not working.

    I was under the impression that you could only call PHP, Perl and a couple others. This would be a pretty easy thing to implement in PHP and would also allow for multiple things to run under one command too

  6. #6
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Cron job to run once a day is not working.

    Quote Originally Posted by lemon-tree View Post
    I was under the impression that you could only call PHP, Perl and a couple others.
    That could very well be. However, I believe that rm is installed as a binary rather than a built-in shell command (it certainly isn't a bash built-in), and should thus be accessible (though the full path to the binary might need to be given). find is definitely a binary. I can't check right now, but I believe both binaries have global execute permission.

    Cron doesn't have any blacklisting or whitelisting capabilities that I'm aware of, so it can't filter out certain binaries.

    Quote Originally Posted by lemon-tree View Post
    This would be a pretty easy thing to implement in PHP and would also allow for multiple things to run under one command too
    Seconded. A script would be much more flexible.
    Last edited by misson; 06-18-2010 at 07:17 PM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: Cron job to run once a day is not working.

    @Mission Files didn't get deleted with old cron job.
    @Zapzack I will try the command suggested with -f option , and see if it works.Otherwise I have to do it with Php.I will post the result here.
    Liked this? Click on the icon on the bottom of post to make me .

  8. #8
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: Cron job to run once a day is not working.

    All commands posted above seems to be not working.I thought this can be problem with server time.So I ran date(r) and used 10 minutes ahead of that time to set cron job.But files are there.
    How can execute Php script using cron and also where I can get tutorial for webmasters about using cron job.Thanks
    Last edited by bhupendra2895; 06-19-2010 at 09:18 AM.
    Liked this? Click on the icon on the bottom of post to make me .

  9. #9
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Cron job to run once a day is not working.

    To execute a PHP cron job, enter this:
    /usr/bin/php /home/YOUR_USERNAME/public_html/PATH_TO_FILE
    In the PHP script you should then use readdir() to get the list of files in the selected directory and then use unlink() to delete each of those files.

  10. #10
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: Cron job to run once a day is not working.

    Thanks lemon-tree, it should do the job.
    Liked this? Click on the icon on the bottom of post to make me .

+ Reply to Thread

Similar Threads

  1. cron job is not working
    By bonsaing in forum Free Hosting
    Replies: 1
    Last Post: 04-13-2010, 01:56 AM
  2. cron job is not working
    By charitymadurai in forum Free Hosting
    Replies: 1
    Last Post: 07-07-2009, 06:17 AM
  3. Cron not working, please help
    By laeresh in forum Scripts & 3rd Party Apps
    Replies: 1
    Last Post: 02-26-2008, 12:38 PM
  4. Cron Not Working
    By BlackIrish in forum Free Hosting
    Replies: 15
    Last Post: 10-11-2007, 02:59 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers