Discussion Locked

Linux managing stuffs

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How do i set the date and time in Linux? Where do I need to commands that I want to run automagically after startup has finished. In other words... I have three lines that I initiate after I login as root everytime I boot the machine. the commands are like the following:

/sbin/ifup eth0

I want these to run only once per boot-up and only once. So I don't want to put them into .bashrc as has been suggested to me before. That would make them run everytime I logged into a shell.

Adam

8 replies

by mangonmd

What version of linux are you using? Look in /etc/rc.d/ you're looking for a file called rc.local You can put your command at the end of this file. If you tell me what OS you are actually running I could be more specific.

by awimsatt

Please look over the comments that I left above and also, can you tell me how to set the date and time? That should be an easy one to answer. I just feel like wasting points and I'm too lazy to RTFM atm.

by awimsatt

One side note, I have tried putting this into /etc/rc.d/local.rc and it did not work. I just placed the command in there at the end of the file as

/sbin/ifup eth0

Do I need to put it inside of the if statement that is in there?

by maxwell edison

Greetings,

To set the system clock under Linux, use the date command. As an example, to set the current time and date to July 31, 11:16pm, type ``date 07312316'' (note that the time is given in 24 hour notation). If you wanted to change the year as well, you could type ``date 073123161998''. To set the seconds as well, type ``date 07312316.30'' or ``date 073123161998.30''. To see what Linux thinks the current local time is, run date with no arguments.

To set the hardware clock, one way isto set the system clock first, and then set the hardware clock to the current system clock by typing ``/sbin/hwclock --systohc'' (or ``/sbin/hwclock --systohc --utc'' if you are keeping the hardware clock in UTC). To see what the hardware clock is currently set to, run hwclock with no arguments. If the hardware clock is in UTC and you want to see the local equivalent, type ``/sbin/hwclock --utc''

Regards,

Maxwell

This discussion is closed to new replies.