Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-23-2013, 01:53 AM   #1
Ankush Seth
LQ Newbie
Registered: Sep 2013
Posts: 20

Rep: Reputation: Disabled
setup and run a cron job

Hello all i am new with crontab and jobs, but after surfing over net i am able to do this
1. i created a text file "demo.txt" with content 1 * * * * /
for making an entry of every minute in cron job.
2.In i wrote "echo hello world"
3. Now when i run using crontab demo.txt

Now the problem is that no message is shown to the terminal.
and for that i modified the text file with
1 * * * * / >/dev/pts/1 2>&1
but problem is again same i can't see any message.

please tell me if i am doing the right thing or what i am missing.
I will be thankful to you!
Old 09-23-2013, 02:43 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,562

Rep: Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811Reputation: 2811
by default crontab does not use terminal (there is no associated tty), so that echo is pointless.
redirecting the output to /dev/pts/1 may or may not work, depending on the permissions (for example the cron job may have no access right to that terminal) and of course /dev/pts/1 may or may not exist.
Old 09-23-2013, 09:55 AM   #3
Senior Member
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
you could also echo >> foo.log inside your and then via CLI tail -f /path/to/foo.log and every min. it should populate with a new line. you could even add a time stamp to each line so you know exactly how well your practice with cron is working.


dtstamp="`date +%F-%A-%H.%M.%S `"

echo "Hello world @ ${dtstamp}." >> ${log}

something like that. it still will not print Hello world to your terminal window, but if you tail it, you will see it and also see the exact date stamp...

[user@user ~]$ dtstamp="`date +%F-%A-%H.%M.%S `"
[user@user ~]$ echo "Hello world @ ${dtstamp}."
Hello world @ 2013-09-23-Monday-10.53.55.
hope that helps.
Old 09-23-2013, 01:42 PM   #4
Registered: Mar 2013
Location: ahmedabad
Distribution: CentOS, Ubuntu, Debian
Posts: 92
Blog Entries: 1

Rep: Reputation: Disabled
simple as that

#crontab -e

1 * * * * /bin/sh /


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Debian daily cron job won't run, but does run in cron.hourly. sandersch Linux - General 7 05-24-2012 01:50 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
Can't get a cron job to run derzok Linux - General 10 12-16-2007 04:00 AM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration