Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I have 2 cron job on is crontab -e 0 0 * * * avast-update 0 12 * * * avast-update this above one works the one below not at ...
  1. #1
    Linux Newbie
    Join Date
    Jan 2010
    Location
    usa
    Posts
    124

    help with crontab please

    I have 2 cron job on is

    crontab -e
    0 0 * * * avast-update
    0 12 * * * avast-update

    this above one works the one below not at all

    sudo crontab -e
    0 3 * * * apt-get update & apt-get dist-upgrade
    0 15 * * * apt-get update & apt-get dist-upgrade

    i have even restrated my computer after i have saved the crontab. anyone have any idea why my jobs are not running? I'm new to this.

  2. #2
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    Code:
    0 15 * * * apt-get update && apt-get dist-upgrade
    or

    Code:
    0 15 * * * apt-get update ; apt-get dist-upgrade
    From bash man pages
    If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. Commands separated by a ; are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed.
    It seems & must be a terminating control operator.

    Just try in a terminal :
    Code:
    ls &
    ls & free
    ls && free
    ls ; free
    I didn't try the above with cron.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  3. #3
    Linux Newbie
    Join Date
    Jan 2010
    Location
    usa
    Posts
    124
    im still having trouble getting this to work. my file says that it is saved into some place called /tmp/crontab. but when i go to see if their is a file in /tmp/.crontab i see nothing and my cron jobs do not work

    sudo crontab -e
    0 3 * * * apt-get update && apt-get dist-upgrade -y
    0 15 * * * apt-get update && apt-get dist-upgrade -y

    even if i do
    sudo crontab -e
    0 3 * * * apt-get update ; apt-get dist-upgrade -y
    0 15 * * * apt-get update ; apt-get dist-upgrade -y

  4. #4
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    Either specify the full path to your programs or define the PATH variable at the beginning of the cron job. You'll perhaps have to define the SHELL variable too. The cron job is found in /var/spool/cron, but you don't have to worry about that.

    Code:
    PATH="/bin:/usr/bin:/usr/local/bin" #JUST AN EXAMPLE
    SHELL="/bin/bash"
    ...
    ...
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  5. #5
    Linux Newbie
    Join Date
    Jan 2010
    Location
    usa
    Posts
    124
    you mean like this please look at my attached pic
    Attached Images Attached Images

  6. #6
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    Not readable !
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  7. #7
    Linux Newbie
    Join Date
    Jan 2010
    Location
    usa
    Posts
    124
    i hope this pic is better
    Attached Images Attached Images

  8. #8
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    Why don't you just copy/paste the data ?

    You have a typo at /bin/bach -> /bin/bash
    You may complete your PATH variable to be exactly the environment PATH one.
    You don't need sudo if it's root cron job.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  9. #9
    Linux Newbie
    Join Date
    Jan 2010
    Location
    usa
    Posts
    124
    You may complete your PATH variable to be exactly the environment PATH one.
    i do not know what you are talking about

    acer@kacer:~$ sudo crontab -e

    PATH ="/bin:/usr/bin:/usr/local/bin"
    SHELL="bin/bash"
    0 16 * * * apt-get update && apt-get dist-upgrade -y # JOB_ID_1
    0 12 * * * apt-get update && apt-get dist-upgrade

  10. #10
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    In a shell, get the environment PATH variable content :

    Code:
    echo $PATH
    and set the cron PATH variable accordingly.

    You have one more typo : bin/bash -> /bin/bash

    There'll be no valid reason left for this cron job to fail.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

Page 1 of 2 1 2 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
  •  
...