I want to upload file into my dropbox when my pc is shutdowning.
sudo vim /etc/systemd/system/upload.service
[Unit]
Description=upload files into dropbox
Before=network.target shutdown.target reboot.target
Requires=network-online.target
[Service]
ExecStop=/bin/true
ExecStart=/bin/bash /home/upload.sh
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
And the upload.sh script.
cd /home
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer xxxx" \
--header "Dropbox-API-Arg: {\"path\":\"/test.txt\",\"mode\":{\".tag\":\"overwrite\"}}" \
--header "Content-Type: application/octet-stream" \
--data-binary @test.txt
`bash upload.sh` can executed successfully,and file uploaded into my dropbox.
sudo systemctl enable upload service
To reboot my pc.
sudo journalctl -u upload
Apr 13 23:58:52 localhost systemd[1]: Started upload files into dropbox.
Apr 13 23:58:52 localhost systemd[1]: Starting upload files into dropbox...
Apr 13 23:58:52 localhost bash[117]: % Total % Received % Xferd Average Speed Time Time Time Current
Apr 13 23:58:52 localhost bash[117]: Dload Upload Total Spent Left Speed
Apr 13 23:58:52 localhost bash[117]: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: content.dropboxapi.com; Un
Apr 13 23:58:52 localhost systemd[1]: upload.service: main process exited, code=exited, status=6/NOTCONFIGURED
Apr 13 23:58:52 localhost systemd[1]: Unit upload.service entered failed state.
Apr 13 23:58:52 localhost systemd[1]: upload.service failed.
How to solve the issue when to upload file into dropbox at shutdown?