Hi,
I was not able to find the "at" command in PhotonOS.
Is there another similar tool available or is it located in a specific repository ?
Regards
To schedule a bash file to automatically run once eg. after a reboot, you could use this, see https://vmware.github.io/photon/assets/files/html/3.0/photon_admin/creating-a-startup-service.html.
Generally, you must create a service file in which you declare what has to be done as "at" one. In the following sample it is simply a bash file which is configured to run once.
# --- 1) create a bash file with content as preparation for the service (see 2). The last part in the bash file direclty disables and unlinks the service.
BASHFILE="/root/mysample.sh"
cat > $BASHFILE <<'EOF'
#!/bin/sh
# INSERT YOUR CODE
systemctl disable mysample.service
rm /lib/systemd/system/multi-user.target.wants/mysample.service
unlink /lib/systemd/system/mysample.service
EOF
# --- 2) make the bash file executable and create the service file. The type of [Service] is configured to 'oneshot'. The Unit dependencies 'after' and 'wants' - in this case- it has a environment dependency to a service called waagent.service. This is optional.
chmod a+x $BASHFILE
cat << EOF1 >> /lib/systemd/system/mysample.service
[Unit]
Description=Run a bash file
After=waagent.service
Wants=waagent.service
[Service]
ExecStart=$BASHFILE
Type=oneshot
[Install]
WantedBy=multi-user.target
EOF1
cd /lib/systemd/system/multi-user.target.wants/
ln -s ../mysample.service mysample.service
# --- 3) 'ln -s' together with the service file allows to simply use the created service within systemctl.
Hope this helps.
For compatibility reasons, Photon supports cron jobs as well. See Does photon OS support cron jobs. I am unable to find any relevant help docs · Issue #620 · vmware/p...
Thanks for your answer.
It is not a convenient solution, as I would like to be able to run a background task without any shell at a desired time and on demand. So no need to configure a cron and forget to unset it for a single-shot maintenance script which must be run in a middle of the night to solve a problem (my typical recurring need).
If the "at" command is definitely unavailable in Photon OS, I am quite surprised as it is very common in the Linux world and not fancy !
Regards
@INSASBGDSIN Photon supports several flavors generic, linux-esx, aws,.You could place your question on Issues · vmware/photon · GitHub why the scheduling algorithm of at_irq.c (?) didn't made it to be kept as one of the affordable scheduling methods. cron is a supported old fallback within systemd though.
I use "at" in photonOS to schedule a task to send emails, "at" isn't in photon's repo and so I had to compile it myself, you might want to do the same ... be sure to create a service file as well !
Hi @INSASBGDSIN
you can install at command, on photon OS 3.0:
yum install wget
wget http://rpmfind.net/linux/mageia/distrib/6/x86_64/media/core/release/at-3.1.20-1.mga6.x86_64.rpm
rpm -ivh --nodeps at-3.1.20-1.mga6.x86_64.rpm
systemctl enable atd
systemctl start atd
best regards