Systemd services aren't executed by a shell, and although
man systemd.service notes the syntax for the various
Exec___ directives is "inspired by shell syntax", it also notes:
redirection using "<", "<<", ">", and ">>", pipes using "|",
running programs in the background using "&", and other elements of shell syntax are not supported.
So you can see there is a problem there. I don't know if that will necessarily mean the service wasn't run, but it will mean it won't log to where you want it to log (see the
StandardError options in
man systemd.exec for that).
Of course, this implies it can still be run manually:
If a type sudo systemctl restart gateway.service ,the program runs normally
So likely the spurious redirection is just being ignored, and not the main problem.
This just seems wrong:
WantedBy = multi-user.target
If you have reason to believe this should work, fair enough. If it is just something you decided upon, I would use something other than
networking.target (check to make sure those are in use with
systemctl status ____ first).
By the way, you do not mention doing this:
sudo systemctl enable [my.service]
Which you must do if you want it run at boot. You can also check after boot to see what happened:
systemctl status [my.service]
There should be some clue there. Also, every time you change the service file you will need to use
sudo systemctl daemon-reload.
Finally, you may want to change the type of the service to either
oneshot, depending on whether this is a persistent, long-running program (
simple) or something that just configures something quickly then exits (