I have two machines, a Rpi4 and Ubuntu PC. The two machines are offgrid and connected to their network. The idea is to sync the RPi4 time with the Ubuntu machine. The NTP aproach failed because port and firewall issues. So I used htpdate instead. I've noticed however that I can not set the correct system time of the Rpi4. Regardless of the command I can not get rid of the offset.
I looked elsewhere on how to sync without success:
synchronising-time-between-two-linux-machines
how-to-sync-raspberry-pi-system-clock
how-to-know-if-htpdate-has-synchronized-system-clock
htpdate.8.en.html
htpdate.php
The problem is I can not get rid of the offset. The output of my sessions are:
pi#CMPL01-003-21:~ $ sudo htpdate -qd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1 80 14 Feb 2023 13:37:24 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1 80 14 Feb 2023 13:37:25 GMT (0.006) => 38
#: 1 mean: 38 average: 38.000
Offset 38.000 seconds
poll 1800 s
pi#CMPL01-003-21:~ $ sudo htpdate -xqd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1 80 14 Feb 2023 13:39:25 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1 80 14 Feb 2023 13:39:26 GMT (0.003) => 38
#: 1 mean: 38 average: 38.000
Adjusting 38.000 seconds
poll 1800 s
pi#CMPL01-003-21:~ $ sudo htpdate -sd 10.42.0.1
burst: 1 try: 1 when: 500000
10.42.0.1 80 14 Feb 2023 13:40:26 GMT (0.003) => 38
burst: 1 try: 2 when: 500000
10.42.0.1 80 14 Feb 2023 13:40:27 GMT (0.005) => 38
#: 1 mean: 38 average: 38.000
Setting 38.000 seconds
Set: Tue Feb 14 14:40:27 2023
poll 1800 s
Is there a missing hidden htpdate parameter or some rules to apply to a folder maybe to clear the offset?
I upgraded the version of htpdate from 1.2.0 to 1.3.7 and tried again. The result was the same and the offset was still there with the difference that the command output noted the client machine was running the automatic ntp sync service. Afterward I was able to sync correctly with htpdate after disabling the service with sudo timedatectl -set-ntp false. Case closed.
Related
Basically, I want to take a time, and day of the week, in UTC+8, and adjust the datetime object to a given UTC offset, within bash, I don't have any code to show because I'm not sure how to start attempting this in the first place honestly
(I'm writing a custom script for a friend who lives in UTC+8 and want to make the input as easy as possible for them, basically they just give it a time in their timezone, and a day of the week, and it'll tell them what date and time that'll be in a different timezone, for an overarching purpose)
For a reference, look at the section 1 of the manual page for "date":
In your shell, just type: man 1 date
or see the online man page:
https://man7.org/linux/man-pages/man1/date.1.html
One way is to parse the date into the number of seconds since epoch (since 1970), and then convert that number of seconds into the format you want:
For example:
$ date +%s --date='2022-12-27 11:30:17 +008'
1672140137
$ date +%c --date='#1672140137'
Tue 27 Dec 2022 06:22:17 AM EST
or you could also convert to ISO format then back to local time
$ date -Iseconds --date='TZ="GMT" 2022-12-22 11:33:44 +08'
2022-12-21T22:33:44-05:00
$ date --date='2022-12-21T22:33:44-05:00'
Wed 21 Dec 2022 10:33:44 PM EST
I hope this helps you get started with some ideas for converting to/from different timezones.
Also, to help with user input, you can show the current month calendar using cal
$ cal
December 2022
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
$ date --date='Fri 08:30'
Fri 30 Dec 2022 08:30:00 AM EST
In the above example, I specified "Fri 08:30" which gets set to the next Friday at 08:30 in the morning for my local timezone.
I have 4 tmux sessions present. When I use
tmux list-sessions
It shows the sessions with some numbers in the brackets. That is:
t128_1: 1 windows (created Thu Jul 19 12:20:44 2018) [71x38]
t128_2: 1 windows (created Thu Jul 19 12:20:54 2018) [71x38]
t3: 1 windows (created Thu Jul 19 12:19:59 2018) [143x40]
t6: 1 windows (created Thu Jul 19 12:20:27 2018) [71x38]
What does the number [AxB] mean? And why t3 session has a different value than the others? Thanks for any explanation.
That's the size of the terminal (143 columns, 40 rows) the last time a client attached to the session.
I try to run command ./jmeter.sh -n -t ../../apache-jmeter-4.0/test-case-2018/jmeter_cron.jmx and i got log message :
Starting the test # Mon Jul 09 17:44:48 ICT 2018 (1531133088159)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary = 0 in 00:00:00 = ******/s Avg: 0 Min: 9223372036854775807 Max: -9223372036854775808 Err: 0 (0.00%)
Tidying up ... # Mon Jul 09 17:44:48 ICT 2018 (1531133088762)
... end of run
It's seem nothing run .
PS: But i run in my desktop ( Windows 10) it's show result as normal . it's the log message from my desktop :
Starting the test # Mon Jul 09 17:09:03 ICT 2018 (1531130943233)
Waiting for possible Shutdown/StopTestNow/Heapdump message on port
4445 summary + 1 in 00:00:01 = 1.4/s Avg: 346 Min: 346
Max: 346 Err: 1 (100.00%) Active: 1 Started: 1 Finished: 0
summary + 6 in 00:00:01 = 5.1/s Avg: 179 Min: 176 Max:
184 Err: 0 (0.00%) Active: 0 Started: 2 Finished: 2 summary =
7 in 00:00:02 = 3.7/s Avg: 203 Min: 176 Max: 346 Err: 1
(14.29%) Tidying up ... # Mon Jul 09 17:09:05 ICT 2018
(1531130945291) ... end of run
Could anyone can help me ?
CSV Data Set Config filename can be tricky in different environments,
Notice you can use absolute path (not in distributed test) but it may be specific for each OS.
You can use Relative path according to path of the active test plan
Notice that Linux can be case sensitive so make sure driven_data.csv all in lower case
Filename Name of the file to be read. Relative file names are resolved with respect to the path of the active test plan. For distributed testing, the CSV file must be stored on the server host system in the correct relative directory to where the JMeter server is started. Absolute file names are also supported, but note that they are unlikely to work in remote mode, unless the remote server has the same directory structure. If the same physical file is referenced in two different ways - e.g. csvdata.txt and ./csvdata.txt - then these are treated as different files. If the OS does not distinguish between upper and lower case, csvData.TXT would also be opened separately.
Double check that:
The file /data/driven_data.csv exists, you will have to copy it from the master node as JMeter doesn't do this automatically
The user account has read access to the /data/driven_data.csv path, if not - grant it using the following command:
sudo chmod -R a+rX /data/driven_data.csv
See online chmod manual page or type man chmod in your terminal to get full help on the command.
Just FYI: the easiest way to implement the data-driven distributed testing in JMeter is using HTTP Simple Table Server which allows sharing the same data file between multiple slave instances so you will not have to copy the file to the remote slaves.
You can install HTTP Simple Table Server using JMeter Plugins Manager
I cannot get a simple trigger on proftpd working. Here is what I did:
<IfModule mod_exec.c>
ExecEngine on
ExecOptions logStderr logStdout
ExecLog /var/log/proftpd/exec.log
ExecOnCommand APPE,STOR /usr/local/bin/proftptest.sh %u %f
</IfModule>
however it keeps on failing with:
Jan 21 17:31:07 mod_exec/0.9.9[22514]: already saw this Exec, skipping
Jan 21 17:31:07 mod_exec/0.9.9[22514]: already saw this Exec, skipping
Jan 21 17:31:07 mod_exec/0.9.9[22514]: preparing to execute '/usr/local/bin/proftptest.sh' with uid 117 (euid 117), gid 65534 (egid 65534)
Jan 21 17:31:07 mod_exec/0.9.9[22514]: + '/usr/local/bin/proftptest.sh': argv[1] = ftp
Jan 21 17:31:07 mod_exec/0.9.9[22514]: + '/usr/local/bin/proftptest.sh': argv[2] = /home/ftp/incoming/Examples.txt
Jan 21 17:31:07 mod_exec/0.9.9[22514]: error: unable to open /dev/null for stdin: No such file or directory
Jan 21 17:31:07 mod_exec/0.9.9[22514]: STOR ExecOnCommand '/usr/local/bin/proftptest.sh' failed: No such file or directory
Jan 21 17:31:07 mod_exec/0.9.9[22514]: already saw this Exec, skipping
Jan 21 17:31:07 mod_exec/0.9.9[22514]: already saw this Exec, skipping
However the script seems fine (running from my user session, default env):
$ ls -al /usr/local/bin/proftptest.sh
-rwxr-xr-x 1 root root 97 Jan 21 17:25 /usr/local/bin/proftptest.sh
I am NOT using DefaultRoot:
$ grep Default /etc/proftpd/proftpd.conf
DefaultServer on
# DefaultRoot ~
What could I possibly be missing ?
As expained in the documentation:
http://www.castaglia.org/proftpd/modules/mod_exec.html#Usage
This module will not work properly for <Anonymous> logins
This document the symptoms, but does not solve the real issue, so moving on to a different ftp server...
Jekyll was working fine for me few weeks back but now all of a sudden it gives me the following error:
TCPServer Error: Address already in use - bind(2)
INFO WEBrick::HTTPServer#start: pid=7300 port=4000
% lsof -i :4000
<fetches nothing>
Even though nothing is running on the port. Below are the details:
% jekyll --version
Jekyll 0.11.2
% where jekyll
/home/bhaarat/.rvm/gems/ruby-1.9.2-p290/bin/jekyll
/usr/bin/jekyll
% ruby --version
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
% rvm --version
rvm 1.10.0
Here is the output
% jekyll --server
Configuration from /home/bhaarat/blog/omnipresent.github.com/_config.yml
Auto-regenerating enabled: /home/bhaarat/blog/omnipresent.github.com -> /home/bhaarat/blog/omnipresent.github.com/_site
[2012-04-21 13:46:40] regeneration: 38 files changed
[2012-04-21 13:46:40] INFO WEBrick 1.3.1
[2012-04-21 13:46:40] INFO ruby 1.9.2 (2011-07-09) [i686-linux]
[2012-04-21 13:46:40] WARN TCPServer Error: Address already in use - bind(2)
[2012-04-21 13:46:40] INFO WEBrick::HTTPServer#start: pid=7382 port=4000
I know the address isn't in use and jekyll is probably breaking for some other reason but throwing that error. What are my options? I've tried re-installing as well.
Type this in your terminal to find out the PID of the process that's using the 3000 port:
$ lsof -wni tcp:3000
Then, use the number in the PID column to kill the process:
$ kill -9 PID
I was not qualified to post comment. So I added a new answer.
I encountered this problem on Mac OS X 10.10.3. And I had never installed/used Jekyll before. I was not able to start jekyll server with its default port number 4000. The reason was that the port was the same as what NoMachine used. With
$ sudo lsof -wni tcp:4000
Note: Running this command without sudo will have no output.
I saw this output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nxd 449 nx 3u IPv4 0x8d22************ 0t0 TCP *:terabase (LISTEN)
nxd 449 nx 4u IPv6 0x8d22************ 0t0 TCP *:terabase (LISTEN)
The port 4000 was occupied by nxd, which was the process started by NoMachine. And
$ sudo kill -9 449
would not work, because NoMachine's nxd process would keep restarting, with a new PID.
Therefore, I had to either:
Changed my jekyll server port in the site _config.yml to another spared one. I appended the line below to _config.yml and it worked.
port: 3000 # change server port to 3000
or
Changed NoMachine's default nxd port, or Uninstall NoMachine
Ctrl-Z doesn't terminate a program, but rather suspends it and sends it to the background. You can resume the program with the "fg" command. To actually terminate it, use Ctrl-C.
The actual error message seems to be bogus and can be ignored. I am getting the same error message "address in use" but jekyll works fine anyway at the expected port.
I have met this problem recently.
I tried out all the method mentioned above, and even restarted my computer, but still couldn't solve it!!! Then I removed the jekyll and installed a new version, it just worked.
gem uninstall jekyll & gem install jekyll (maybe you need super user priviledge).
If you really get annoyed with similar bugs, this sb method is worth a try...
Based on the top answer, I came up with a simple way
lsof -wni tcp:3000 | xargs -I{} kill -9 {}
It takes the output of finding PID in which port the tcp server is running at. In this case it is 3000.
It then kills the processes running that
PID
Check that you don't have another terminal open where you are already running a server.
If that is the case, do a CTRL-C to shutdown the server, and that will free the port/address.
First you need to find PID of the process that's using the 3000 port:
$ps -ef
Output Like this:
1003 4953 2614 0 08:51 pts/0 00:00:00 -bash
1003 5634 1 0 08:56 pts/0 00:00:00 spring server | moviestore | started 2 hours ago
1003 5637 5634 0 08:56 ? 00:00:01 spring app | moviestore | started 2 hours ago | development mode
1003 6078 4953 0 09:03 pts/0 00:00:03 puma 3.6.0 (tcp://localhost:3000) [moviestore]
1003 6117 2614 0 09:03 pts/1 00:00:00 -bash
root 6520 2 0 09:57 ? 00:00:00 [kworker/u8:2]
root 6936 1225 0 11:09 ? 00:00:00 [lightdm] <defunct>
1003 7084 1 0 11:09 ? 00:00:00 /usr/bin/python /usr/share/apport/apport-gtk
1003 7475 1 0 11:10 ? 00:00:00 /usr/bin/python /usr/share/apport/apport-gtk
root 8739 1225 1 11:29 tty8 00:00:11 /usr/bin/X :1 -auth /var/run/lightdm/root/:1 -nolisten tcp vt8 -novtswitch
root 8853 1225 0 11:29 ? 00:00:00 lightdm --session-child 13 22
1002 8943 1 0 11:30 ? 00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
1002 8954 8853 0 11:30 ? 00:00:00 gnome-session --session=ubuntu
1002 8992 8954 0 11:30 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntu
1002 8995 1 0 11:30 ? 00:00:00 /usr/bin/dbus-launch --exit-with-session gnome-session --session=ubuntu
1002 8996 1 0 11:30 ? 00:00:00 //bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
1002 9007 8954 0 11:30 ? 00:00:00 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
1002 9015 1 0 11:30 ? 00:00:00 /usr/lib/gvfs/gvfsd
1002 9018 8954 1 11:30 ? 00:00:07 compiz
1002 9021 1 0 11:30 ? 00:00:00 /usr/lib/x86_64-linux-gnu/gconf/gconfd-2
1002 9028 8954 0 11:30 ? 00:00:00 /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
1002 9029 8954 0 11:30 ? 00:00:01 nautilus -n
1002 9030 8954 0 11:30 ? 00:00:00 /usr/lib/gnome-settings-daemon/gnome-fallback-mount-helper
1002 9031 8954 0 11:30 ? 00:00:00 nm-applet
1002 9032 8954 0 11:30 ? 00:00:02 /opt/mTrac/mTrac
1002 9033 8954 0 11:30 ? 00:00:00 bluetooth-applet
1002 9045 9032 0 11:30 ? 00:00:00 /opt/mTrac/mTrac --type=zygote --no-sandbox
1002 9050 1 0 11:30 ? 00:00:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
1002 9054 1 0 11:30 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslog
1002 9057 1 0 11:30 ? 00:00:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
1002 9062 1 0 11:30 ? 00:00:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
here you can see :
1003 6078 4953 0 09:03 pts/0 00:00:03 puma 3.6.0 (tcp://localhost:3000) [moviestore]
localhost:3000 have pid: 6078
kill that process by
$sudo kill 6078
then run
$rails s
we can user fuser command
fuser -k 3000/tcp
work around
in /_site run: python -m SimpleHTTPServer 8080