0

I am very new to this. There is tuptime.db file which has records of uptime in my computer(local server). How can I upload it to web server and show the database content in a website. I want something that database in the web server updates itself from local server and show it to the website.

life tree
  • 55
  • 1
  • 7

2 Answers2

2

From your other question I see that you use tuptime.

To keep the DB synchronized you would need to copy it to your webserver every time it is locally updated. This assumes that your local computer is the only process that updates the DB and no other computer synchronizes with the webserver. You can store the DB under a different name on the webserver for each local computer if you need that.

The DB gets updated during startup and shutdown and regularly by a cronjob or a systemd timer. You need to amend all these jobs so that the file is copied to the webserver after every update.

For the shutdown event this might be a bit tricky because the network might already be down when the tuptime update process is triggered so you cannot copy the file to the server any more.

Once the file is copied to the webserver you can (and need to) write a web application that reads the content of the DB, prefereably with parameters set by the web user, and then display the results in a table or something.

The file can be copied with e.g. scp, i.e.:

scp /var/lib/tuptime/tuptime.db user@webserver:/var/lib/tuptime/tuptime-$HOSTNAME.db

To make this run unattended you need to append your local public ssh key (usually ~/.ssh/id_rsa.pub) to the ~user/.ssh/authorized_keys file on the webserver.

Given the above points you can see that it is not as simple as issuing one single command.

Fabby
  • 35,017
PerlDuck
  • 13,885
1

You should be able to use scp /path/to/local/file user@remoteserver.url:/path/to/destination

More information on the scp command can be found here (https://help.ubuntu.com/community/SSH/TransferFiles)