PDA

View Full Version : Real-time in console



BLooDMaN
20th May 2007, 01:13 PM
Hi everyone!

I've a task to show real-time in the bottom of console display using crontab. I've written the correct code to show time in the bottom, but it refreshes only when I enter any command and press enter (I'm sing PROMPT_COMMAND). crontab refreshes time only once a minute, but I need real-time. My classmate used something like "real-clock", I don't remember, so I ca't do this task myself. Please, if anyone know the right command, tell me =)

Thanks a lot!

BLooDMaN
20th May 2007, 04:36 PM
Sorry, PROMPT_COMMAND doesn't work with cron. And `date +%H:%M:%S`, too. Only `date` =( Really need community help.

mwette
20th May 2007, 06:34 PM
I think you would get more help if you provided some context for your problem.

Are you looking for a bash PROMPT_COMMAND that will provide time? Do you
want your prompt to show running time?

Is this a gnome-terminal issue where you want the time on the title bar?

BLooDMaN
20th May 2007, 06:42 PM
So. I don't use GUI at all, my task is to make running time (as you told, thanks for correction) in the bottom of console.
My PROMPT_COMMAND to show time in the bottom with all the features, my teacher told looks like this:

PROMPT_COMMAND='echo -ne
"\e7\e[2;$((LINES-1))r\e[$((LINES-1));1B\e[40m\e[K\e[6G\e[42m\e[K\e[$((COLUMNS/2-4))G\e[30m\e[41m`date
+%H:%M.%S`\e[K\e[42m\e[K\e[$((COLUMNS-5))G\e[40m\e[K\e8"'

Now I get to the /var/spool/cron and write there for my user this:

* * * * * echo PROMPT_COMMAND='echo -ne
"\e7\e[2;$((LINES-1))r\e[$((LINES-1));1B\e[40m\e[K\e[6G\e[42m\e[K\e[$((COLUMNS/2-4))G\e[30m\e[41m`date
+%H:%M.%S`\e[K\e[42m\e[K\e[$((COLUMNS-5))G\e[40m\e[K\e8"' > /dev/tty1

It doesn't work. So I understood, PROMPT_COMMAND doesn't work this way.
Then I tryed this:

* * * * * echo `date` > /dev/tty1

It works nice, but if I add to date +%H, nothing appears.

mwette
21st May 2007, 02:57 AM
What about


$ export PS1="\t$ "
18:56:43$


If this looks like what you want, check the bash man page ("man bash") and
search for the section named PROMPTING.

It might do well to read the bash man page anyway.

BLooDMaN
22nd May 2007, 05:19 AM
What about


$ export PS1="\t$ "
18:56:43$


If this looks like what you want, check the bash man page ("man bash") and
search for the section named PROMPTING.

It might do well to read the bash man page anyway.

Nop, this way doesn't suits me. PS1 and PS2 shouldn't have any changes. Console should look the same as always, except real-time clock in the middle of bottom with other colors.
I looked through the bash manual and didn't find `date` at all. When I put `date` in cron, it shows me full date and if I add +%H it shows nothing.

BLooDMaN
22nd May 2007, 10:47 AM
Latest changes: I found (in Wikipedia) that `date` with cron should be used with \ before %.
But so on I can't find the proper command what shows real-time each second.

markkuk
22nd May 2007, 01:26 PM
Cron works at one-minute resolution, it's impossible to run a cronjob every second. You must use a different solution if you really want a clock with seconds display.

BLooDMaN
22nd May 2007, 05:07 PM
Cron works at one-minute resolution, it's impossible to run a cronjob every second. You must use a different solution if you really want a clock with seconds display.

Yeah, I understand this. I think, I have to start with cron command, which shows the time. But I can't find any.

BLooDMaN
25th May 2007, 11:16 PM
So, the answer wasn't difficual. I had to write a script file, which every second shows the time and start this script every minute (because script works 60 seconds). Thanks everyone for comments, I'm having a new question about bash, but it will appear in a few minutes in new post. =)