Multiple Crontabs into one script file?

Discussion in 'Programming' started by CeramicTree, Oct 19, 2009.

  1. #1
    Hello everyone! :)

    Thank you for taking the time to read this.
    My question is straightforward:

    I have 15 crontabs running in the cPanel of my hosted site.

    Is there a way I can put them all into one script, then have the script run every minute?

    Is there a better way?

    I though to run the script every minute so that as soon as it matches the time condition (like one that is 40 16 * * *), it runs.
    Ideas?


    Thanks for the time and help!! :D
    Very much appreciated!
     
    CeramicTree, Oct 19, 2009 IP
  2. epikpoker

    epikpoker Well-Known Member

    Messages:
    213
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #2
    You could put them all into 1 php file and just cron the php file every minute?
     
    epikpoker, Oct 19, 2009 IP
  3. CeramicTree

    CeramicTree Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have no idea.

    Is the .php file just... dump them in there?

    With the 0 10 * * * before the crontab?

    Thanks! :rolleyes:
     
    CeramicTree, Oct 19, 2009 IP
  4. epikpoker

    epikpoker Well-Known Member

    Messages:
    213
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    116
    #4
    What are the scripts you are running?

    Try this - http://www.htmlcenter.com/blog/running-php-scripts-with-cron/
     
    epikpoker, Oct 19, 2009 IP
  5. CeramicTree

    CeramicTree Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi! Thanks for the help! :)

    Here is an example of one of them:
    cd /home/comoesta/public_html/camera; for i in `ls -I historic`; do cp $i `basename $i .jpg`-1700.jpg && mv *-1700.jpg /home/comoesta/public_html/camera/historic; done
    Code (markup):
    All of them are basically the same.
    They take all the files inside the folder, and copy them into the /historic with the attached text (in this case, "-1700").
     
    CeramicTree, Oct 19, 2009 IP
  6. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #6
    That is easy just make a shell script. Create a file put each statement like that on its own line. Actually put #!/bin/sh in the first line then the rest in their own lines. Change the permissions of the file so it is executable then create one cron job with /path/to/file as the the job.
     
    superdav42, Oct 19, 2009 IP
  7. CeramicTree

    CeramicTree Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    SUPER!!!
    I'm going to try that out now...
    Will update tomorrow, as the schedules run across the day.

    Quick Question:
    The cron job for the job... should it run
    1 * * * * ??

    Or somehow else?
    I am still learning regarding cron jobs/tabs/shell.

    THANKS a lot!!! :D :D
    Very much appreciated
     
    CeramicTree, Oct 19, 2009 IP