i am configuring cronjob to output every minute but it ended up having an empty txt file (hello.txt) in root. These are the files and codes used:

Testcron.sh file:


/root/libvmi/examples/Test1 TestVM1

vi /etc/crontab:

* * * * * root /root/Testcron.sh >> hello.txt

Am i doing it correctly? Please help.

Thanks :)

  • 1
    What is the output of the Testcron.sh file when you execute manually?
    – tachomi
    Sep 22, 2015 at 18:51
  • 1
    Revise root /root/Testcron.sh >> hello.txt to be root /root/Testcron.sh >> hello.txt 2>errors.txt so that you capture any error output.
    – steve
    Sep 22, 2015 at 18:53
  • @tachomi The output of Testcron.sh is the process list and the domain information of the Guest VM, for this instance, it is TestVM1. I am able to run at command line but have no idea why i can't do it when it is placed as a cronjob :(
    – Joy Woong
    Sep 23, 2015 at 1:10
  • @steve Managed to capture the error output stating that there is a path error for /root/libvmi/examples/Test1 to open. What i normally do for that error is: export LD_LIBRARY_PATH=/usr/local/lib is this counted as a path? if do, may i know which file should i put this file in? Thanks! :)
    – Joy Woong
    Sep 23, 2015 at 1:11
  • Joy, based on the result from steve's suggestion, you should add that LD_LIBRARY_PATH=/usr/local/lib in front of the /root/libvmi/examples/Test1 command (or on the line above it).
    – Jeff Schaller
    Sep 24, 2015 at 1:55

2 Answers 2


(Capturing the comments into a bona fide answer for this question)

@steve suggested:

Revise root /root/Testcron.sh >> hello.txt to be root /root/Testcron.sh >> hello.txt 2>errors.txt so that you capture any error output

From which @Joy saw that there was an error, and they needed to set:

export LD_LIBRARY_PATH=/usr/local/lib

before running the Test1 command. The resulting Testcron.sh file is then:


export LD_LIBRARY_PATH=/usr/local/lib
/root/libvmi/examples/Test1 TestVM1

What if you try running crontab -e command as root and setup your job there?

# crontab -e
* * * * * /root/Testcron.sh >> hello.txt

It's not recommended to edit /etc/crontab file. Here you can see the difference between crontab -e & editing /etc/creontab file.

From this page

This file could be used for other cron commands, but probably shouldn't be. Here's an example line from a ficticious /etc/crontab 00 01 * * * rusty /home/rusty/rusty-list-files.sh This would run Rusty's command script as user rusty from his home directory. However, it is not usual to add commands to this file. While an experienced user should know about it, it is not recommended that you add anything to /etc/crontab. Apart from anything else, this could cause problem if the /etc/crontab file is affected by updates! Rusty could lose his command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .