From the comments and your updated question I read you want to run your script not every day at 11pm but only once the next day at 11pm. While this is possible with cron
I suggest using an at
job instead.
When adding a cronjob for this, we would need to calculate the next day's date (to setup something like 0 23 2 10 * …
for Oct 2) and then again remove that cronjob the next day. As said: possible but cumbersome. Hence, an at
job. You may need to install the at
command via sudo apt install at
.
The syntax of at
is a bit surprising: the command to be run is not given as a parameter but read from stdin, so we need to pipe it into at
. Some examples:
echo "ls -l > out1.txt" | at now + 2 minutes
echo "ls -l > out2.txt" | at 23:00
echo "ls -l > out3.txt" | at tomorrow
In your case:
echo "./test-script.sh" | at 23:00
This will run test-script.sh
the next time it is 11pm.
at
job, not acron
job.at
jobs are run just once at some time in the future. Might that better suit your needs?if
won't trigger...