LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-03-2008, 12:04 PM   #1
trillobyte
Member
 
Registered: Apr 2007
Location: USA
Distribution: Slackware, FreeBSD, Trisquel
Posts: 105
Blog Entries: 1

Rep: Reputation: 33
Need help running cron in Slackware 12.1


Hello:

I am going through a Crontab tutorial and have reached a roadblock.

I have tried the following test as a user and as root using crontab -e:

* * * * * /usr/bin/wall "Hello From Crontab"

I get no response or messages as I instructed.

I did a ps -aux | grep crond and it shows crond running:

root 2838 0.0 0.0 1912 632 ? S May30 0:00 /usr/sbin/crond -l10

I can't figure out why cron will not run as both a user and root for me.
Any help will be appreciated.

Best regards
 
Old 06-03-2008, 12:18 PM   #2
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
That's really nifty, I didn't know about the "wall" command. However, your syntax is incorrect. I tested `/usr/bin/wall "Hello From Crontab"` and received an error. `wall` is expecting a file to display instead of a message. There are two options. You could create a file with those contents and use `/usr/bin/wall < /path/to/file.txt`, or you could use `/usr/bin/echo "Hello From Crontab" | /usr/bin/wall`. Either one will work.
 
Old 06-03-2008, 12:30 PM   #3
trillobyte
Member
 
Registered: Apr 2007
Location: USA
Distribution: Slackware, FreeBSD, Trisquel
Posts: 105

Original Poster
Blog Entries: 1

Rep: Reputation: 33
Quote:
Originally Posted by T3slider View Post
That's really nifty, I didn't know about the "wall" command. However, your syntax is incorrect. I tested `/usr/bin/wall "Hello From Crontab"` and received an error. `wall` is expecting a file to display instead of a message. There are two options. You could create a file with those contents and use `/usr/bin/wall < /path/to/file.txt`, or you could use `/usr/bin/echo "Hello From Crontab" | /usr/bin/wall`. Either one will work.
Thanks for the reply. I tried the /usr/bin/echo "Hello From Crontab" | /usr/bin/wall and I still get no response from cron. I have also tried the getmail command to retrieve my e mail but it looks like cron is refusing to respond for some reason. Getmail works if I try it manually.
 
Old 06-03-2008, 12:56 PM   #4
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
I just tested it as my normal user and this seems to work:
Code:
$ crontab -l
* * * * * /path/to/script.sh
script.sh consists of the following:
Code:
$ cat /path/to/script.sh
#!/bin/sh

/usr/bin/echo "Hello From Crontab" | /usr/bin/wall
I could get cron to perform the wall command but the message wasn't carrying through with my previous suggestions (it was just a blank message), and using quotes didn't seem to help the issue. This solution works, however.

An easy way to test whether or not cron is working is to delete your current crontab (`crontab -d`) and add the following line:
Code:
$ crontab -l
* * * * * DISPLAY=:0.0 /usr/bin/xmessage "Hello"
If you are in an X session, you'll get a dialog box popping up once a minute.
 
Old 06-03-2008, 01:19 PM   #5
trillobyte
Member
 
Registered: Apr 2007
Location: USA
Distribution: Slackware, FreeBSD, Trisquel
Posts: 105

Original Poster
Blog Entries: 1

Rep: Reputation: 33
Quote:
Originally Posted by T3slider View Post
I just tested it as my normal user and this seems to work:
Code:
$ crontab -l
* * * * * /path/to/script.sh
script.sh consists of the following:
Code:
$ cat /path/to/script.sh
#!/bin/sh

/usr/bin/echo "Hello From Crontab" | /usr/bin/wall
I could get cron to perform the wall command but the message wasn't carrying through with my previous suggestions (it was just a blank message), and using quotes didn't seem to help the issue. This solution works, however.

An easy way to test whether or not cron is working is to delete your current crontab (`crontab -d`) and add the following line:
Code:
$ crontab -l
* * * * * DISPLAY=:0.0 /usr/bin/xmessage "Hello"
If you are in an X session, you'll get a dialog box popping up once a minute.
I tried that and it's not working.
 
Old 06-03-2008, 01:20 PM   #6
trillobyte
Member
 
Registered: Apr 2007
Location: USA
Distribution: Slackware, FreeBSD, Trisquel
Posts: 105

Original Poster
Blog Entries: 1

Rep: Reputation: 33
I meant I tried the * * * * * DISPLAY=:0.0 /usr/bin/xmessage "Hello"
and it didn't work. I did it as root.
 
Old 06-03-2008, 02:49 PM   #7
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
You may wish to direct your error output to a file to see what's happening. Something like the following would do nicely:
Code:
$ crontab -l
* * * * * DISPLAY=:0.0 /usr/bin/xmessage "Hello" 2> /path/to/error.txt
That way you could see if there are any errors. You may also wish to direct standard out to a file as well. Something like the following would throw every message into a file:
Code:
$ crontab -l
* * * * * DISPLAY=:0.0 /usr/bin/xmessage "Hello" 2>&1 > /path/to/error.txt
 
Old 06-03-2008, 03:01 PM   #8
trillobyte
Member
 
Registered: Apr 2007
Location: USA
Distribution: Slackware, FreeBSD, Trisquel
Posts: 105

Original Poster
Blog Entries: 1

Rep: Reputation: 33
Well I tried it and this is what the error.txt indicates:

No protocol specified
Error: Can't open display: :0.0


Best regards
 
Old 06-03-2008, 03:22 PM   #9
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Well, that at least means that crond is working. I won't try to determine why the xmessage thing isn't working because it isn't relevant to the wall command (though it probably has something to do with running the crontab entry as root, or possibly something's awry if you use runlevel 4). You could try doing the same with the wall script I posted above to see why it isn't working.
 
Old 06-03-2008, 04:00 PM   #10
trillobyte
Member
 
Registered: Apr 2007
Location: USA
Distribution: Slackware, FreeBSD, Trisquel
Posts: 105

Original Poster
Blog Entries: 1

Rep: Reputation: 33
I got it to work doing it as a script...* * * * * /path/to/script.sh
I'm happy knowing that Cron is working. I really appreciate the help you have given me T3slider.

Best regards
 
  


Reply

Tags
cronjob



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
Cron not running sometimes yuiy88 Linux - Newbie 6 02-14-2008 02:37 AM
cron is not workin well running a custom script on Slackware 10.1... sugar2 Linux - Software 3 08-24-2006 07:41 PM
cron.allow and cron.deny in slackware? tl64 Slackware 5 10-13-2005 09:44 PM
Cron Job Not Running pzorn Linux - General 4 10-02-2003 01:38 PM
Cron not running Half_Elf Linux - Software 4 01-10-2003 02:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:07 AM.

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