Find the answer to your Linux question:
Results 1 to 7 of 7
Hello guys!! This is my first post in this wonderful community, by just browsing this forum i leanred soo much about linux! Anyways, i have a questions about cron jobs ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Posts
    3

    Cron jobs - how to? - SSH - Time in command line?


    Hello guys!!
    This is my first post in this wonderful community, by just browsing this forum i leanred soo much about linux!
    Anyways, i have a questions about cron jobs on SSH
    note: i am a noobie.
    other notes: i am using a client called "PuTty" for SSH.
    I am running CentOs (same as linux redhat)

    I would like to setup cronjobs (sceduled task) on 3 files to run every 3 minute.
    This is for a mail script that is suppose to check for mail and send me support tickets.
    The files are located in a folder on my server
    (absolute path : home/domain/www/support/email/users.php / techmail.php / mail.php)

    I am having trouble figuring out what path to type in the SSH command line, although i do know that my command would have to look somthing like this:
    */1 * * * -wget -q [path to file]

    please remember i am a noobie so do not laugh if my command makes no sense

    My second question is, whats he difference between "command line version of php" and "apache module of php"

    Last question: I was following a tutorial last night and i was typing in a command in SSH as directed by the tut (it was a cronjob)
    and whenever i typed in the time which was represented by ( 0 3 * * * )
    for 3am... SSH would say that the command is invalid, and whever i ran the cron without that part (0 3 * * *) it would work and apply the cron ONCE only. so i guess my concern is.. how do i type in the time in correct format on the command line for SSH ?

    is it 0 3 *** with no spaces?
    or 0 3 * * * spaced out?

    Sorry for being ignorant but an answer to my questions would def brighten me up!!!

    Thanks for reading!

    Ben.

  2. #2
    Linux User
    Join Date
    Feb 2005
    Posts
    290
    as a normal user, i do crontab this way:

    edit my crontab file (say /home/adam/mycrontab) and put the following:
    Code:
    # minutes hours day_of_month month day_of_week      /usr/bin/command_to_be_run
    1 * * * * /run/this/every/1st/minute
    then

    Code:
    [adam@linux] $ cat /home/adam/mycrontab | crontab
    as root user, you can always edit /etc/crontab and save the trouble of having to edit the file then |crontab again.

    good luck

  3. #3
    Linux Enthusiast puntmuts's Avatar
    Join Date
    Dec 2004
    Location
    Republic Banana
    Posts
    562
    Modern distro's come with a different way of specifying crontabs. There is this set of directories in /etc (cron.*) where you can place executable scripts. But that is mainly designed to run as root.

    The entry wich will give you a job every 3 minutes looks like this:
    Code:
    #<minute> <hour> <day> <month> <dow> <command>
    /3 * * * * /home/user/command
    This is with spaces. To edit your cron entries use
    Code:
    crontab -e <user>
    rather then editing files using some editor. The user part is optional and can be used by root to edit some user crontab.
    I\'m so tired .....
    #200472

  4. #4
    Linux User
    Join Date
    Feb 2005
    Posts
    290
    Quote Originally Posted by puntmuts
    To edit your cron entries use
    Code:
    crontab -e <user>
    rather then editing files using some editor. The user part is optional and can be used by root to edit some user crontab.
    yeap, but i doubt a newbie would really love to vi in that way :P

  5. #5
    Linux Enthusiast puntmuts's Avatar
    Join Date
    Dec 2004
    Location
    Republic Banana
    Posts
    562
    Quote Originally Posted by adam7979
    yeap, but i doubt a newbie would really love to vi in that way :P
    That is true, but a broken crontab data file doesn't help the newbie either, and some basic vi is part of the game
    I\'m so tired .....
    #200472

  6. #6
    Linux Enthusiast
    Join Date
    Jun 2002
    Location
    San Antonio
    Posts
    621
    Another way to do this is with the nano editor, which comes as an alternate in RedHat (and thus in centOS). You can run:

    Code:
    EDITOR=/usr/bin/nano crontab -e
    Then in here, _THIS_ is where you enter the code for the crontab. In this case it is:

    Code:
    */3 * * * * wget -q http&#58;//test.com/test.php
    Best,

    Samuel
    I respectfully decline the invitation to join your delusion.

  7. #7
    Just Joined!
    Join Date
    Mar 2005
    Posts
    3
    you guys are too good!

    thanks so much for the input, all of you!


    cheers,
    ben

Posting Permissions

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