Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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
    Harrow, UK
    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!"

  3. #3
    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. $spacer_open
  5. #4
    Linux Guru
    Join Date
    Oct 2007
    Tucson AZ
    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.

  6. #5
    Thanks much appriciated

  7. #6
    Linux Enthusiast sgosnell's Avatar
    Join Date
    Oct 2010
    Baja Oklahoma
    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