Script not running at startup

I am having check.sh script and check.service which I include to /etc/systemd/system/

chmod 744 /usr/local/bin/check.sh
chmod 664 /etc/systemd/system/check.service
systemctl daemon-reload
systemctl enable check.service
check.sh:
websockify 5555 localhost:7000 &
date > /home/john/date.txt

websockify is installed correctly and when I run this only in terminal it is good, but script not run this part on startup. I put a test date to export to file and this line is ok, but why first isn't?

Linux is 18.04 Ubuntu

You may have better results if you use the full path of this command in your script:

/your/full/path/to/this/bin/websockify

Check/Show file contents of ...

/etc/systemd/system/check.service

Check/Show output of...

systemctl status check.service
 /etc/systemd/system/check.service
/etc/systemd/system/check.service: line 1: [Unit]: command not found
/etc/systemd/system/check.service: line 2: After: command not found
/etc/systemd/system/check.service: line 4: [Service]: command not found
/etc/systemd/system/check.service: line 7: [Install]: command not found
/etc/systemd/system/check.service: line 8: WantedBy: command not found
root@test:~# WebSocket server settings:
  - Listen on :5555
  - Flash security policy server
  - No SSL/TLS support (no cert file)
  - proxying from :5555 to localhost:7000
root@test:~# systemctl status check.service
�- check.service
   Loaded: loaded (/etc/systemd/system/check.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2019-02-13 18:55:47 CET; 47s ago
  Process: 1489 ExecStart=/usr/local/bin/check.sh (code=exited, status=0/SUCCESS)
 Main PID: 1489 (code=exited, status=0/SUCCESS)

феб 13 18:55:47test systemd[1]: Started check.service.

This is systemd check file

[Unit]
After network.target = auditd.service

[Service]
ExecStart= /usr/local/bin/check.sh

[Install]
WantedBy = multi-user.target

--- Post updated at 01:07 PM ---

tried, and nothing happend, ports are closed, only when put in terminal its gonna run

ss -an |grep 7000
ss -an |grep 5555

You did execute the unit file. That does not work. It's not a script.

a) Change your unit file to:

[Unit]
After=network.target

[Service]
ExecStart=/usr/local/bin/check.sh
Type=simple

[Install]
WantedBy=multi-user.target

b) Change your script(check.sh)

date > /home/john/date.txt
/path/to/websockify 5555 localhost:7000
 

Don't sent websockify to background, let it run in foreground. Both is possible, but letting it run in foreground is simpler. Run the tests before websockify not after. (tests are not needed really needed anyway, you have systemctl status ). You may add set -x to the start of your script to see what's being run with systemctl status. (or journalctl -u check.service )

You may add debug command line options to the websockify call. Anything that is printed on stdout will be in the log you get with systemctl status / journalctl.

Thanks for it, now it seems its ok a part of it. Port 5555 is listening but 7000 not.

-- Reboot --
феб 13 20:11:24 kladionica systemd[1]: Started check.service.
феб 13 20:11:39 kladionica check.sh[583]: WebSocket server settings:
феб 13 20:11:39 kladionica check.sh[583]:   - Listen on :5555
феб 13 20:11:39 kladionica check.sh[583]:   - Flash security policy server
феб 13 20:11:39 kladionica check.sh[583]:   - No SSL/TLS support (no cert file)
феб 13 20:11:39 kladionica check.sh[583]:   - proxying from :5555 to localhost:7000

this is a last line of .sh file, it seems ok when I put it like this in terminal

/usr/bin/socat -u TCP-LISTEN:7000,fork,reuseaddr,bind=127.0.0.1 SYSTEM:"lp -d MYPRNT $1"
/path/to/websockify 5555 localhost:7000

I thought port 7000 was reserved for afs3 fileserver...

Maybe,but its not open on my system..

--- Post updated at 03:18 AM ---

And when I execute only in terminal its ok.
Why dont enable it when put it to script.

well because when you run a script in batch mode e.g. using cron or init you are using utilities with minimalist intelligence e.g. like PATH=/bin:/usr/bin
In other words when you log in you have access to an environment, which is unknown in batch mode
The most important when it works in interactive and not in batch is to start with PATH variable:
put in your script at the beginning the path you have when you type env
If that doesnt work source your .profile or whatever you use as first line of your script knowing that it will generate loads of errors because not in interactive mode ( all things to do with stty to start with...) and see if that works, if so you are to search what in your env is needed to get your script to work...
Good luck

For learning how to configure and manage services with systemd look at the documentation, for example here:

manpages

And here a more tutorial styled website:

Understanding and Using Systemd | Linux.com | The source for Linux information

--- Post updated at 12:49 PM ---

Maybe the program needs a terminal and it is not configured to have one in the service file?