Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Cron jobs...

  1. #1
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Cron jobs...

    I set crontabs before on debian and Ubuntu.
    Now i am trying to do the same stuff with opensuse.
    what i want to do is:
    I have php files, i want to run it after 5 minutes by cron.
    So far i have this:
    */5 * * * * /usr/bin/php /var/www/monitoring/cron.php
    Which was working fine before on other systems.
    I have to configure crontab in terminal like:
    crontab -e
    But when i try to type this '*', what i get is :
    E348: No string under cursor
    Any ideas, i face this before and solved it, but now out of my mind.
    Does any body have idea of multiple crons, mean just write all cron jobs in a file and run that file by cron.
    I have some idea.
    file:
    */5 * * * * /usr/bin/php /var/www/monitoring/cron.php
    */5 * * * * /usr/bin/php /var/www/monitoring/vibration.php
    Now run it under cron like:
    */5 * * * * /var/www/monitoring/file.txt
    Is it correct.

    All ideas are welcomed.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  2. #2
    ab@novell.com NNTP User

    Default Re: Cron jobs...

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    The "error" about 'No string under cursor' is because you are using 'vi'
    or 'vim' for editing your crontab and you are in command mode instead of
    insert mode. Before you put your '*' on the line type 'i' which will
    put you in the mode to insert text. Then enter your entire line and,
    when done, press the [Esc] key. At this point either enter the following:

    :wq!

    or hold [Shift] and press the 'z' key twice

    ZZ

    Good luck.





    mmarif4u wrote:
    > I set crontabs before on debian and Ubuntu.
    > Now i am trying to do the same stuff with opensuse.
    > what i want to do is:
    > I have php files, i want to run it after 5 minutes by cron.
    > So far i have this:
    >> */5 * * * * /usr/bin/php /var/www/monitoring/cron.php

    > Which was working fine before on other systems.
    > I have to configure crontab in terminal like:
    >> crontab -e

    > But when i try to type this '*', what i get is :
    >> E348: No string under cursor

    > Any ideas, i face this before and solved it, but now out of my mind.
    > Does any body have idea of multiple crons, mean just write all cron
    > jobs in a file and run that file by cron.
    > I have some idea.
    > file:
    >> */5 * * * * /usr/bin/php /var/www/monitoring/cron.php
    >> */5 * * * * /usr/bin/php /var/www/monitoring/vibration.php
    >>

    > Now run it under cron like:
    >> */5 * * * * /var/www/monitoring/file.txt
    >>

    > Is it correct.
    >
    > All ideas are welcomed.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIxgOd3s42bA80+9kRAghxAJ48ywdaB6EPONTU+H79BiLHFdwlIACghrD7
    2dD+D0oKwpvcdWUNe7E0Gzc=
    =0Op5
    -----END PGP SIGNATURE-----

  3. #3
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Cron jobs...

    Quote Originally Posted by mmarif4u View Post
    But when i try to type this '*', what i get is :

    Any ideas, i face this before and solved it, but now out of my mind.
    If you do a google for "no string under cursor" you will get this hit:

    Tip #1 - the super star : vim online

    It simply means you have not entered insert mode in vim, so the * is treated as a command meaning search forward for word under cursor. Tip: the # key does the same in the reverse direction.

    Vim is a very powerful editor with lots of programmer oriented short command sequences. If you are not familiar with vim, perhaps you should use a simpler editor like nano or joe. You can set your preferred visual editor with "export VISUAL=nano" in ~/.bashrc.

    Does any body have idea of multiple crons, mean just write all cron jobs in a file and run that file by cron.
    Just put multiple lines in your crontab like you have posted, that's the simplest way.

    Code:
    */5 * * * * /usr/bin/php /var/www/monitoring/cron.php
    */5 * * * * /usr/bin/php /var/www/monitoring/vibration.php

  4. #4
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Re: Cron jobs...

    Thanks ab@novell.com.
    I forgot the I and zz method. now its working fine.

    @ken_yap:
    Thanks to you to for a detailed post specially export.
    Can i put gedit as a editor there.
    ~/.bashrc will be from my home dir.am i right.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Cron jobs...

    gedit, I dunno, probably, but then you will only be able to edit when you have a GUI desktop running.

  6. #6
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Re: Cron jobs...

    Thanks for the info.
    I tried to run the multiple crons in a file.
    what i get in the mail is:
    /var/www/CSL_monitoring_2/cron.txt: line 1: */2: No such file or directory
    /var/www/CSL_monitoring_2/cron.txt: line 2: */2: No such file or directory
    file is cron.txt:
    */2 * * * * /usr/bin/php /var/www/monitoring_2/cron.php
    */2 * * * * /usr/bin/php /var/www/monitoring_2/cron_vibration.php
    cron is:
    */2 * * * * /var/www/CSL_monitoring_2/cron.txt
    all files are in the same dir.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  7. #7
    ab@novell.com NNTP User

    Default Re: Cron jobs...

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Um, I think we have a bit of confusion here. The line where you are
    trying to execute what appears to be a text file? That doesn't make any
    sense.... put the lines that call the 'php' executable directly in the
    resulting window from your 'crontab -e' command. Those lines would be,
    per your post:

    */2 * * * * /usr/bin/php /var/www/monitoring_2/cron.php
    */2 * * * * /usr/bin/php /var/www/monitoring_2/cron_vibration.php

    The 'crontab -e' isn't looking for you to specify a file that will be
    interpreted by cron.... it is the file/configuration to be interpreted
    by cron. Anyway, put the lines above in there.

    Also, about the file not existing, you mentioned all files were in the
    same directory, but these are not the same directories:

    /var/www/monitoring_2/
    /var/www/CSL_monitoring_2/

    One of them has 'CSL' in it, which is apparently wrong.

    Good luck.





    mmarif4u wrote:
    > Thanks for the info.
    > I tried to run the multiple crons in a file.
    > what i get in the mail is:
    >> /var/www/CSL_monitoring_2/cron.txt: line 1: */2: No such file or
    >> directory
    >> /var/www/CSL_monitoring_2/cron.txt: line 2: */2: No such file or
    >> directory
    >>

    > file is cron.txt:
    >> */2 * * * * /usr/bin/php /var/www/monitoring_2/cron.php
    >> */2 * * * * /usr/bin/php /var/www/monitoring_2/cron_vibration.php

    >
    > cron is:
    >> */2 * * * * /var/www/CSL_monitoring_2/cron.txt

    >
    > all files are in the same dir.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIxhPV3s42bA80+9kRAieIAJ9R62yLEjNrhUPgdNy/gKmyAZfb0gCfSG7K
    IkmN0BUgbsIGEOucB9FNObY=
    =NhgP
    -----END PGP SIGNATURE-----

  8. #8
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Cron jobs...

    No, don't bother with cron.txt, just put those two lines directly in the crontab, that's what I was trying to tell you.

    Code:
    */2 * * * * /usr/bin/php /var/www/monitoring_2/cron.php
    */2 * * * * /usr/bin/php /var/www/monitoring_2/cron_vibration.php

  9. #9
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Re: Cron jobs...

    @ken_yap
    I understand what you said in last post. but i was trying to do it like that way.i did that before in ubuntu, and was working fine.
    i know about to put multiple lines in cron.I tried because some time we use crontab -r, which will delete all the lines there. but having in a file, you can add one file each time. Also editing is easy.
    Anyway, thanks for the ideas.
    Will try to go around it more.

    @ab@novell.com
    The directory was same, i mistakenly changed it in that post.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  10. #10
    ab@novell.com NNTP User

    Default Re: Cron jobs...

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    While the abilitiy to chain configs indefinitely may be possible, it
    doesn't make much sense unless you are blocking the ability for
    individual users to use cron on their own (e.g. via `crontab -e`) since
    it requires not provides the opportunity for a lot of confusion, it also
    means (in most cases) you aren't giving anything new except that
    complexity. The cron daemon also needs to recognize something as NOT an
    executable but instead as a config file, which could be done a few ways
    but could also be tricky to implement. I'm not sure I can think of a
    reason why chaining them would be helpful except in how SUSE already
    does it for the root user, of sorts, using /etc/cron.daily,
    /etc/cron.hourly, etc. These directories don't contain additional cron
    configurations but instead have the actual scripts that are to be run
    per time period (by directory name) directly, which is convenient when
    you want a daily script since you just drop it in /etc/cron.daily and
    let the system take care of it. Again, this is for the 'root' user.
    Any other user can add as many lines as they like to their own
    configuration (assuming cron is enabled for them, which may not be the
    case) by using the `crontab -e` command you've been using. This runs
    anything in there as that user and is up to them entirely what they do
    without any other administrator intervention.

    Good luck.






    mmarif4u wrote:
    > @ken_yap
    > I understand what you said in last post. but i was trying to do it like
    > that way.i did that before in ubuntu, and was working fine.
    > i know about to put multiple lines in cron.I tried because some time we
    > use crontab -r, which will delete all the lines there. but having in a
    > file, you can add one file each time. Also editing is easy.
    > Anyway, thanks for the ideas.
    > Will try to go around it more.
    >
    > @ab@novell.com
    > The directory was same, i mistakenly changed it in that post.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIxhsK3s42bA80+9kRAs1jAJsFXyUMjixkf4lvjehabmfKCnzlCACghGJT
    Pwq4cKlgu60FdCtw/b8UWwk=
    =974K
    -----END PGP SIGNATURE-----

Page 1 of 2 12 LastLast

Posting Permissions

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