Thread: Crontab

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    68
    Rep Power
    3

    Smile Crontab


    hi, i have update.txt file with perl script, and i want to use crontab to schedule that file run every 1 hour. how can i do that? please help!!!!
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    15
    Rep Power
    0
    Originally Posted by andreas.london
    hi, i have update.txt file with perl script, and i want to use crontab to schedule that file run every 1 hour. how can i do that? please help!!!!
    1. Perl scripts don't have .txt extensions. Rename it .pl
    2. chmod +x it
    3. you'll have to determine when to it is supposed to run
    4. crontab -e
    5. create the crontab entry as specified in the man pages (man crontab)
    6. Save and Exit
    7. Make sure crontab service is running.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    68
    Rep Power
    3

    Smile crontab


    hi, thanks very much for you help.
    i just wondering also if you know how can i email those scheduled updates to my email address???
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,448
    Rep Power
    1751
    Just a small point ... you can call your script anything you want ... even iexplore.exe, *nix does not care. The only ones who will care are you and anyone else using the system.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    68
    Rep Power
    3
    thanks very much for the tip!

    Originally Posted by SimonJM
    Just a small point ... you can call your script anything you want ... even iexplore.exe, *nix does not care. The only ones who will care are you and anyone else using the system.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    15
    Rep Power
    0
    Originally Posted by SimonJM
    Just a small point ... you can call your script anything you want ... even iexplore.exe, *nix does not care. The only ones who will care are you and anyone else using the system.
    While this is true, it's definitely not good practice. Sysops come and go, properly identifying files is key to a successful administration team. If there is no particular reason to name the file ambiguously (like security reasons) my 2 cents is that you name it appropriately. It's just a good habit to get into.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    68
    Rep Power
    3
    hm. i see! ok thanks a lot! Can you please help me as well with the email using cron?
    Originally Posted by safesurfdns
    While this is true, it's definitely not good practice. Sysops come and go, properly identifying files is key to a successful administration team. If there is no particular reason to name the file ambiguously (like security reasons) my 2 cents is that you name it appropriately. It's just a good habit to get into.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    15
    Rep Power
    0
    Originally Posted by andreas.london
    hm. i see! ok thanks a lot! Can you please help me as well with the email using cron?
    In RedHat variants crontab mails automatically if you have postfix and dovecot set up properly...
  16. #9
  17. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886
    Originally Posted by andreas.london
    hm. i see! ok thanks a lot! Can you please help me as well with the email using cron?
    In your crontab file, include the following line:
    Code:
    MAILTO=myemail@example.com
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    68
    Rep Power
    3
    does this command has any limitations? because i tried that before and it didn't work.
    Originally Posted by ishnid
    In your crontab file, include the following line:
    Code:
    MAILTO=myemail@example.com
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,448
    Rep Power
    1751
    Generally cron will only mail output from a script/binary. If your output is directed to a file then that will not do what you want - unless you then cat the file.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  22. #12
  23. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,897
    Rep Power
    3886
    Originally Posted by andreas.london
    does this command has any limitations? because i tried that before and it didn't work.
    In what way did it not work? No email at all? Wrong content?

    Presumably you need to have a mailer such as exim set up.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    68
    Rep Power
    3
    No email at all. I think it didn't work because i have to configure smtp server. if that could be a reason can you please tell me what i can do?

    Originally Posted by ishnid
    In what way did it not work? No email at all? Wrong content?

    Presumably you need to have a mailer such as exim set up.

IMN logo majestic logo threadwatch logo seochat tools logo