How to auto run xrandr to rotate screen 90 degree when ubuntu desktop start-up

Dear Technical Support,

The following is my steps:
1. Create service file on /etc/systemd/system/xxx-app.service

[Unit]
Description=Gui Application
After=lightdm.service
[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/opt/nvidia/l4t-usb-device-mode/xxx-app.sh
[Install]
WantedBy=graphical.target

2. Create script file /opt/nvidia/l4t-usb-device-mode/xxx-app.sh:
#!/bin/bash
set -e
export DISPLAY=:0
mkdir -p /tmp/test1
/usr/bin/xrandr -o left
mkdir -p /tmp/test2
cd - # Out of /sys/kernel/config/usb_gadget
exit 0

3. Run the command “systemctl enable xxx-app.service” to config the service on start-up

Reboot, I don’t see the effect rotate screen. it seem failed to run command “/usr/bin/xrandr -o left”
I can see folder /tmp/test1 been created but /tmp/test2 not create.
Under manual open terminal, The command “xrandr -o left” is working correctly.
Would you please give me any advice to resolve the issues?

Thanks
Martin

I remembered there was one method for this. You could use the GUI -> system setting ->display setting to rotate the monitor first.

After that, it will generate a config file under home directory. You could copy the format of that config file to other device so that it would rotate by default in each boot.