한동안 나는 systemd
내가 만든 유닛이 명령 출력을 systemd
로그에 기록하도록 강제하려고 노력해 왔습니다. 내 구성은 다음과 같습니다 syslog
.
$ cat /etc/systemd/system/sf-synchronize.service
[Unit]
Description=Synchronize Files With GCS Bucket
[Service]
ExecStart=/snap/bin/gcloud storage rsync --recursive --exclude="^lost\\+found/.*$|^.*/tmp/.*$" "/mnt/disks/storage/" "gs://XXXXXX/2023-11/"
StandardOutput=journal
StandardError=journal
서비스를 로드하기 위한 구성은 다음과 같습니다.
$ sudo systemctl show sf-synchronize.service | grep 'Standard\|Exec'
ExecMainStartTimestamp=n/a
ExecMainStartTimestampMonotonic=0
ExecMainExitTimestamp=n/a
ExecMainExitTimestampMonotonic=0
ExecMainPID=0
ExecMainCode=0
ExecMainStatus=0
ExecStart={ path=/snap/bin/gcloud ; argv[]=/snap/bin/gcloud storage rsync --recursive --exclude=^lost\+found/.*$|^.*/tmp/.*$ /mnt/disks/storage/ gs://XXXXXX/2023-11/ ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStartEx={ path=/snap/bin/gcloud ; argv[]=/snap/bin/gcloud storage rsync --recursive --exclude=^lost\+found/.*$|^.*/tmp/.*$ /mnt/disks/storage/ gs://XXXXXX/2023-11/ ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
StandardInput=null
StandardOutput=journal
StandardError=journal
MemoryDenyWriteExecute=no
서비스를 몇 번 사용하기 시작했지만 로그 sudo systemctl start sf-synchronize.service
에 아무것도 없습니다 .systemd
$ sudo journalctl -u sf-synchronize.service
Mar 01 16:01:58 salesforce-archive systemd[1]: Started Synchronize Files With GCS Bucket.
Mar 01 16:03:59 salesforce-archive systemd[1]: sf-synchronize.service: Deactivated successfully.
실제 명령 출력은 다음 위치에 있습니다 syslog
.
$ sudo tail -f /var/log/syslog
Mar 1 16:02:12 salesforce-archive gcloud[3946]: At file:///mnt/disks/storage/**, worker process 3910 thread 140482368034624 listed 32000...
Mar 1 16:02:23 salesforce-archive gcloud[3946]: At gs://XXXXXX/2023-11/**, worker process 3910 thread 140482368034624 listed 32000...
Mar 1 16:02:24 salesforce-archive gcloud[3946]: At file:///mnt/disks/storage/**, worker process 3910 thread 140482368034624 listed 64000...
Mar 1 16:02:41 salesforce-archive gcloud[3946]: At file:///mnt/disks/storage/**, worker process 3910 thread 140482368034624 listed 96000...
Mar 1 16:02:46 salesforce-archive gcloud[3946]: At gs://XXXXXX/2023-11/**, worker process 3910 thread 140482368034624 listed 64000...
Mar 1 16:02:54 salesforce-archive gcloud[3946]: At file:///mnt/disks/storage/**, worker process 3910 thread 140482368034624 listed 128000...
Mar 1 16:03:02 salesforce-archive gcloud[3946]: At file:///mnt/disks/storage/**, worker process 3910 thread 140482368034624 listed 146597...
Mar 1 16:03:08 salesforce-archive gcloud[3946]: At gs://XXXXXX/2023-11/**, worker process 3910 thread 140482368034624 listed 96000...
Mar 1 16:03:29 salesforce-archive gcloud[3946]: At gs://XXXXXX/2023-11/**, worker process 3910 thread 140482368034624 listed 128000...
Mar 1 16:03:41 salesforce-archive gcloud[3946]: At gs://XXXXXX/2023-11/**, worker process 3910 thread 140482368034624 listed 146597...
Mar 1 16:03:58 salesforce-archive gcloud[3910]:
ubuntu-2204-jammy-v20240228
이미지를 사용하여 GCP의 가상 머신에서 실행합니다.
$ cat /etc/issue
Ubuntu 22.04.4 LTS \n \l
다른 서비스는 어떻게든 로그인하지만 이 서비스는 그렇지 않습니다. 이 문제를 해결하는 방법? 감사해요