Find the answer to your Linux question:
Results 1 to 6 of 6
Hi Im new to linux, using ubuntu 10.04. I have been playing around with crontab and have no problems scheduling a job which runs a script file containing the following ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2010
    Posts
    38

    running scripts from crontab


    Hi Im new to linux, using ubuntu 10.04.

    I have been playing around with crontab and have no problems scheduling a job which runs a script file containing the following command:

    mkdir Desktop/testdir.

    However, when I try to do the following in the script file nothing happens..

    top -b -n 1 > /tpm/topoutput.txt

    Similarly the following doesnt do anything either:

    ifconfig > Desktop/ifconfigoutput.txt

    Is there something im missing?

    Any help would be appriciated

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,206
    Yes, you're missing the same thing I did! Cron is usually run by a special cron user who does not have the same command path as root (there is probably be a security reason for this). Consequently scripts that are to be run by cron need full path names for all commands.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Just Joined!
    Join Date
    Oct 2010
    Posts
    38
    cheers, but what exactly do you mean by full paths?...

    from the examples in my previous post the script file that runs a mkdir command works fine, its just the top and ifconfig commands that dont..

    if you could elaborate that would be brilliant, im really new to this

  4. #4
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190
    Instead of using:
    ifconfig > Desktop/ifconfigoutput.txt
    use: /sbin/ifconfig Desktop/ifconfigoutput.txt

    Similar for top: /usr/bin/top -b -n 1 > /tpm/topoutput.txt

    You can find where ifconfig and top are on your system with whereis or locate commands if the above doesn't work.

  5. #5
    Just Joined!
    Join Date
    Oct 2010
    Posts
    38
    Thanks much appriciated

  6. #6
    Linux User sgosnell's Avatar
    Join Date
    Oct 2010
    Location
    Baja Oklahoma
    Posts
    467
    The absolute path for Desktop is /home/user/Desktop, where user is the username of the user who owns the desktop. Desktop is a valid path only from /home/user, nowhere else.

Posting Permissions

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