0

I'm trying to make crontab run a sh script every 5 minutes.

This is my root (sudo crontab -e) crontab setup:

*/5 * * * * /etc/test.sh

and this is the script:

#!/bin/bash
echo "time:$(date)"

EDIT: i've made it work by using the user crontab file (crontab -e) but I still need to run my script with administrative privileges...

  • Did you make your script executable? – troylatroy Jan 8 '14 at 19:18
  • 1
    Where do you expect the output of the echo command to go? The cron process does not run in a terminal (in particular it does not run in the terminal from which you invoked the crontab command). If you look in /var/log/syslog you will probably find a log entry confirming that the job did in fact run (provided the script is executable). – steeldriver Jan 8 '14 at 22:13
  • executable scripts shouldn't be kept in /etc - that folder is for configuration files. /usr/local/bin would be a much better choice. – ImaginaryRobots Jan 8 '14 at 22:24
1

First make sure your script is executable! If so, it can also be because PATH is not set, have a look at this post and its replies:
Reasons why crontab does not work

Also my suggestion would be using cron.d instead of making a mess in crontab file.

| improve this answer | |
0

If you want a notification in a balloon at the upper right of youe screen where all the other notifications show up, try this command:

 notify-send "$(date)"
| improve this answer | |
  • I'm using ubuntu server so it'll not work – user2702899 Jan 8 '14 at 19:35
  • Right you are. I guessed you were the more traditional desktop user. – Marc Jan 8 '14 at 21:01
0

This doesn't solve the problem the way you wanted to, but it just might git'r'done anyway.

PS1="(\$(date +%H:%M) $PS1"

That will put the time in hour:minute format into your shell prompt. Hit {Enter} on an empty prompt, get the time. Works just dandy on my servers.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.