Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
2
answers
1982
views
How to pass command line arguments to bash script when executing with at?
I have a bash script needs run at a specific time and found out `at` is pretty much does what I need to do. But the problem is I'm not sure how can I pass command line arguments to the bash script through `at`. Below command is what I finally ended up after looking through some other solutions. echo...
I have a bash script needs run at a specific time and found out
at
is pretty much does what I need to do. But the problem is I'm not sure how can I pass command line arguments to the bash script through at
. Below command is what I finally ended up after looking through some other solutions.
echo "-f job.sh argument" | xargs at now + 2 minutes
But this does not work. Can anyone help me with this?
yash
(1 rep)
Jan 23, 2020, 06:34 PM
• Last activity: Jul 21, 2025, 10:06 AM
0
votes
1
answers
172
views
Can't shutdown Linux guest OS with `at` command
Here are three examples of what I did inside the terminal (the third one has sudo): 1. ``` at now + 5 minutes ``` (interactively:) ``` at> shutdown --poweroff now ``` 2. ``` echo "sbin/shutdown -h now" | at 14:50 ``` 3. ``` echo "/sbin/shutdown -h 16:22" | at now ``` In every case, I can verify the...
Here are three examples of what I did inside the terminal
(the third one has sudo):
1.
at now + 5 minutes
(interactively:)
at> shutdown --poweroff now
2. echo "sbin/shutdown -h now" | at 14:50
3. echo "/sbin/shutdown -h 16:22" | at now
In every case,
I can verify the one-time job is scheduled with the atq
command,
but the shutdown --show
command says "No scheduled shutdown".
The system should shutdown at the scheduled time that at
runs
after sleeping.
This is on a CentOS 9 Stream guest virtual machine.
The user is already added to the sudo users group
and can initiate the shutdown with a command like shutdown now
.
So, with the one-time at
job, what’s the difference?
Samir Fink
(3 rep)
Mar 5, 2024, 09:25 PM
• Last activity: May 26, 2025, 09:48 AM
1
votes
1
answers
48
views
How to see the content of an appointment in a queue of commands of AT command
I know i can see the schedule with `atq`, but this brings me only the timedate of the execution and not wich command wil be executed. ``` [root@myserver ~]# atq 1Thu Oct 31 04:45:00 2024 a root ``` Using `at -c 1` it spits all the job, and a lot of configs (at this point for me is only garbage). Is...
I know i can see the schedule with
atq
, but this brings me only the timedate of the execution and not wich command wil be executed.
[root@myserver ~]# atq
1Thu Oct 31 04:45:00 2024 a root
Using at -c 1
it spits all the job, and a lot of configs (at this point for me is only garbage).
Is there any way to see only de pure command that will be executed?
A_Figueiredo
(11 rep)
Oct 30, 2024, 07:27 PM
• Last activity: Oct 31, 2024, 03:43 AM
1
votes
3
answers
215
views
How to execute mpg123 at given time with at
I was testing few things, nothing is working. I have this command called `~/bin/beep` for sound notifications. ```bash #!/bin/bash mpg123 -q /home/kuba/Pobrane/beep-6.mp3 ``` I usually use it like this: ```bash sleep 4m && beep ``` and I'm trying to execute it at the give time with at. I was testing...
I was testing few things, nothing is working.
I have this command called
~/bin/beep
for sound notifications.
#!/bin/bash
mpg123 -q /home/kuba/Pobrane/beep-6.mp3
I usually use it like this:
sleep 4m && beep
and I'm trying to execute it at the give time with at. I was testing by specifing next minute.
I was trying:
at 14:01 /home/kuba/at.log
No error, no sound.
How should I execute mpg123
with at
?
jcubic
(10310 rep)
Jul 26, 2024, 12:13 PM
• Last activity: Jul 27, 2024, 11:47 PM
0
votes
1
answers
1487
views
Schedule a script with arguments using 'at'
I have a bash script and I want to run it at a given time. Usually I would write something like this to run it immediately: ./my_script.sh 1 1 n 8 3 keywords here I am trying to execute the same command using the "[at][1]" command but it doesn't work. If I run this, for example: at 2230 -f my_script...
I have a bash script and I want to run it at a given time.
Usually I would write something like this to run it immediately:
./my_script.sh 1 1 n 8 3 keywords here
I am trying to execute the same command using the "at " command but it doesn't work.
If I run this, for example:
at 2230 -f my_script.sh 1 1 n 8 3 keywords here
I get this error:
syntax error. Last token seen: 1
Garbled time
How can I run the script with arguments at a given time?
Robb1
(297 rep)
Feb 10, 2020, 06:52 PM
• Last activity: Jul 14, 2024, 10:14 PM
0
votes
1
answers
134
views
start command at given time interactively in terminal
is there similar command to `sleep`, but where I can specify given time, so that my command will start at given time, **INTERACTIVELY** in my current open terminal window? I know about `at` command, but that would not work as it does not run interactively in my current open terminal window. I need t...
is there similar command to
sleep
, but where I can specify given time, so that my command will start at given time, **INTERACTIVELY** in my current open terminal window?
I know about at
command, but that would not work as it does not run interactively in my current open terminal window.
I need to start my command at 04:00 in my terminal, as if I woke up, typed my command, and pressed enter.
The closest solution I can think of, is to calculate before I go to bed, how many seconds remain until 04:00, and use sleep
command. But that is so ugly. There must be a better way to do this.
Martin Vegter
(586 rep)
Apr 27, 2024, 05:49 AM
• Last activity: Apr 27, 2024, 10:18 AM
0
votes
3
answers
165
views
"at" command does not run desired program / script
I am trying to learn scheduling with the "at" command, and therefore, I want to test it out and keep things simple. For example, when I type `"at 00:28"` (my time zone's format), and then enter `/usr/bin/leafpad`, I expect leafpad to start at 00:28. That does not happen though. Nothing happens, basi...
I am trying to learn scheduling with the "at" command, and therefore, I want to test it out and keep things simple.
For example, when I type
"at 00:28"
(my time zone's format), and then enter /usr/bin/leafpad
, I expect leafpad to start at 00:28. That does not happen though. Nothing happens, basically.
When I check the related job id with "at -c jobid"
, the tail of it says "Execution directory inaccessible".
That's pretty weird, because when I type in "/usr/bin/leafpad"
, leafpad actually opens up.
I am using Kali Linux btw.
popsmoke
(1 rep)
Mar 6, 2024, 03:32 PM
• Last activity: Mar 7, 2024, 11:17 AM
0
votes
1
answers
120
views
How to run a one-off command at a specified future time in Guix?
I want to run a shell command once at a specific time in the future on Guix. My idea was to use the `at` command, but that seems to not be available on Guix. The imperative nature of my desire goes against the declarative philosophy of Guix somewhat, which I expect is the (indirect) reason `at` is n...
I want to run a shell command once at a specific time in the future on Guix. My idea was to use the
at
command, but that seems to not be available on Guix.
The imperative nature of my desire goes against the declarative philosophy of Guix somewhat, which I expect is the (indirect) reason at
is not available.
For example, at
requires atrun
or atd
to be running, which might not fit nicely in the Guix way of doing things.
Is there perhaps a Guix-specific way of running a command at a specific time that I have not found yet?
For the moment I can just do a sleep xxx; cmd
, which should be good enough for now.
----
This is my solution based on @GAD3R suggestion to use mcron
, and the [manual on how to emulate at
](https://www.gnu.org/software/mcron/manual/mcron.html#AT-commands)
~/.config/hello.guile
:
(job '(next-minute-from (current-time) '(25))
(lambda () (system "echo $(date) >> ~/hello.txt")
(kill (getppid) SIGINT)))
and then call mcron
.
This indeed added a line to ~/hello.txt
at 25 minutes past the hour.
It is a bit more work than using at
, but it does work.
Two potential improvements I can see:
* It seems that job
simply expects a function that returns a unix timestamp as first argument. So I suppose it would be feasible to give it the exact timestamp that is necessary. That might also make the killing part redundant.
* I suppose that instead of calling mcron
manually, it is maybe better to use the [mcron Home Service](https://guix.gnu.org/en/manual/devel/en/html_node/Mcron-Home-Service.html)
Finally, maybe it would be worthwhile to explicitly state that mcron
replaces also atd
or atrun
, as those where terms I knew and searched for. For some reason I did not think that cron should also be able to approximate what I looked for. Maybe I'll write a patch.
BlackShift
(313 rep)
Feb 18, 2024, 08:19 PM
• Last activity: Feb 19, 2024, 10:51 AM
3
votes
2
answers
3442
views
mutt send mail from command line, with headers inside text file
Can mutt send mail from command line without command line parameters, with subject, cc, bcc, reply-to, in-reply-to all defined inside mail.txt file with body of the message too (the same file format like mutt opens to me when i press m-send mail, or r-reply to mail). ... So that I can: - press 'r' o...
Can mutt send mail from command line without command line parameters, with subject, cc, bcc, reply-to, in-reply-to all defined inside mail.txt file with body of the message too (the same file format like mutt opens to me when i press m-send mail, or r-reply to mail).
... So that I can:
- press 'r' on received mail, prepare my reply message, save it with ':w ~/preparedmail.txt' in vim ... cancel sending
- and than run $ at 8:00 <<< "mutt < ~/preparedmail.txt"
... or is there other tool that will accept this file format. Or other way to achieve this.
Asain Kujovic
(2178 rep)
Nov 6, 2015, 05:57 AM
• Last activity: Nov 30, 2023, 03:34 AM
12
votes
4
answers
3596
views
sort at jobs chronologically
Possibly a simple solution I misplaced. How can I get the output of `atq` sorted chronologically, so I can easily see who's due to run next? The `man` page for `sort` doesn't have anything built-in to recognize timestamps like the following: atq 1264 Sat Mar 24 15:03:00 2012 a master 1445 Sat Mar 24...
Possibly a simple solution I misplaced.
How can I get the output of
atq
sorted chronologically, so I can easily see who's due to run next? The man
page for sort
doesn't have anything built-in to recognize timestamps like the following:
atq
1264 Sat Mar 24 15:03:00 2012 a master
1445 Sat Mar 24 20:28:00 2012 a master
1548 Sun Mar 25 15:09:00 2012 a master
1193 Sat Mar 24 11:03:00 2012 a master
1359 Sat Mar 24 17:13:00 2012 a master
1726 Mon Mar 26 21:24:00 2012 a master
1736 Mon Mar 26 22:04:00 2012 a master
1748 Mon Mar 26 22:46:00 2012 a master
1704 Mon Mar 26 20:19:00 2012 a master
1288 Sat Mar 24 15:38:00 2012 a master
1532 Sun Mar 25 11:53:00 2012 a master
atq |sort
wouldn't work either at the job id's jump around.
Marcos
(2353 rep)
Mar 23, 2012, 11:05 AM
• Last activity: Nov 3, 2023, 04:26 PM
0
votes
3
answers
110
views
How does at behave when going off the end of a month with a relative date?
When using `at midnight next month` and it is the 31 of January, how will it behave? Will it be the 4th of March or 28 of February? or the 31 of March?
When using
at midnight next month
and it is the 31 of January, how will it behave?
Will it be the 4th of March or 28 of February? or the 31 of March?
Caesar
(25 rep)
Aug 27, 2023, 02:38 PM
• Last activity: Aug 29, 2023, 03:51 PM
0
votes
2
answers
2907
views
exit the prompt by `at` command
I want to set a cron at a specific time and I am using at for that. However at puts you in a special prompt. Is there a way I can exit the prompt in my code without having to use CTRL + D?
I want to set a cron at a specific time and I am using at for that. However at puts you in a special prompt. Is there a way I can exit the prompt in my code without having to use CTRL + D?
user2851669
(143 rep)
Dec 11, 2016, 01:08 AM
• Last activity: Jul 25, 2023, 02:45 AM
2
votes
2
answers
142
views
at jobs: queue IDs and job files
``` root@calleva:/var/spool/cron/atjobs# echo "sleep 3000" | at 20:58 warning: commands will be executed using /bin/sh job 161 at Sat Jun 3 20:58:00 2023 root@calleva:/var/spool/cron/atjobs# ls a000a101acba0e root@calleva:/var/spool/cron/atjobs# cat a000a101acba0e #!/bin/sh # atrun uid=0 gid=0 # mai...
root@calleva:/var/spool/cron/atjobs# echo "sleep 3000" | at 20:58
warning: commands will be executed using /bin/sh
job 161 at Sat Jun 3 20:58:00 2023
root@calleva:/var/spool/cron/atjobs# ls
a000a101acba0e
root@calleva:/var/spool/cron/atjobs# cat a000a101acba0e
#!/bin/sh
# atrun uid=0 gid=0
# mail root 0
umask 22
LANGUAGE=en_GB:en; export LANGUAGE
PWD=/var/spool/cron/atjobs; export PWD
LOGNAME=root; export LOGNAME
XDG_SESSION_TYPE=tty; export XDG_SESSION_TYPE
MOTD_SHOWN=pam; export MOTD_SHOWN
HOME=/root; export HOME
LANG=en_GB.UTF-8; export LANG
SSH_CONNECTION=192.168.0.12\ 60848\ 192.168.0.113\ 22; export SSH_CONNECTION
XDG_SESSION_CLASS=user; export XDG_SESSION_CLASS
USER=root; export USER
SHLVL=0; export SHLVL
XDG_SESSION_ID=1202; export XDG_SESSION_ID
XDG_RUNTIME_DIR=/run/user/0; export XDG_RUNTIME_DIR
SSH_CLIENT=192.168.0.12\ 60848\ 22; export SSH_CLIENT
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet/tools:/root/bin:/opt/mssql-tools/bin:/usr/games; export PATH
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus; export DBUS_SESSION_BUS_ADDRESS
SSH_TTY=/dev/pts/5; export SSH_TTY
OLDPWD=/root; export OLDPWD
cd /var/spool/cron/atjobs || {
echo 'Execution directory inaccessible' >&2
exit 1
}
sleep 3000
root@calleva:/var/spool/cron/atjobs# atq
161 Sat Jun 3 20:58:00 2023 a root
root@calleva:/var/spool/cron/atjobs#
Is there a way to tell that file a000a101acba0e
corresponds to queue item 161
?
Richard Barraclough
(550 rep)
Jun 2, 2023, 10:00 PM
• Last activity: Jun 3, 2023, 11:24 AM
0
votes
1
answers
293
views
How does atd store its job schedule?
On CentOS, scheduled `at` jobs are clearly stored in `/var/spool/at`, one file per job. However, what's not clear is where the start times for the jobs are stored. Job file names are a 14 character hex string (e.g. `a0000101ac6c40`). Is the start time somehow encoded in the file name, or is it store...
On CentOS, scheduled
at
jobs are clearly stored in /var/spool/at
, one file per job. However, what's not clear is where the start times for the jobs are stored. Job file names are a 14 character hex string (e.g. a0000101ac6c40
). Is the start time somehow encoded in the file name, or is it stored elsewhere?
ETA: By scheduling two jobs one minute apart, it does appear as if the file name contains the start time, but I haven't been able to figure out how to decode it. Anyone know?
Swechsler
(147 rep)
May 16, 2023, 06:43 PM
• Last activity: May 16, 2023, 10:36 PM
0
votes
0
answers
69
views
How can Linux "at" be used to open a gnome-terminal window?
Using "at" to execute a shell command that writes to a file works. Using it to open a gnome-terminal does not work. OS: Ubuntu 20.04 A file containing a command to write the date to a file was created and made executable. date-file.sh: `date > date.txt` This line was entered. `at now -f date-file.sh...
Using "at" to execute a shell command that writes to a file works. Using it to open a gnome-terminal does not work.
OS: Ubuntu 20.04
A file containing a command to write the date to a file was created and made executable.
date-file.sh:
date > date.txt
This line was entered.
at now -f date-file.sh
As expected, the file date.txt was created and contained the date string.
The (redacted) output of sudo systemctl status atd
showed
May 16 05:25:25 - atd: pam_unix(atd:session): session opened for user - by (uid=1)
May 16 05:25:25 - atd: pam_unix(atd:session): session closed for user -
A file containing a command to open a gnome-terminal was created and made executable.
open-term.sh: /usr/bin/gnome-terminal
This line was entered. at now -f open-term.sh
No error was reported in the terminal, but nothing seemed to happen. No gnome-terminal window opened.
The (redacted) output of sudo systemctl status atd
showed
May 16 05:31:32 - atd: pam_unix(atd:session): session opened for user - by (uid=1)
May 16 05:31:32 - atd: pam_unix(atd:session): session closed for user -
May 16 05:31:32 - atd: Exec failed for mail command: No such file or directory
Both command files are in the current directory, and the gnome-terminal command is given with an absolute path, so I don't understand the cause of the "No such file or directory" error.
Can the "at" command be used to open a terminal window?
Thank you for any help.
bac-cab
(1 rep)
May 16, 2023, 10:28 PM
13
votes
1
answers
21925
views
at command: Garbled time
I am not able to run `at` command. edward@ArchLinux:~$ at Garbled time what is wrong? Am I running it wrong?
I am not able to run
at
command.
edward@ArchLinux:~$ at
Garbled time
what is wrong? Am I running it wrong?
Alex Jones
(6483 rep)
Feb 2, 2016, 07:17 PM
• Last activity: May 12, 2023, 12:37 PM
0
votes
2
answers
696
views
how to specify precise date to atd
I found some examples here: http://www.thegeekstuff.com/2010/06/at-atq-atrm-batch-command-examples But how can I create at job with specific time that contains minutes, seconds and even year, like `2018-01-15 08:00:00`? What is the format of input date/time?
I found some examples here: http://www.thegeekstuff.com/2010/06/at-atq-atrm-batch-command-examples
But how can I create at job with specific time that contains minutes, seconds and even year, like
2018-01-15 08:00:00
? What is the format of input date/time?
Petr
(1791 rep)
Dec 18, 2017, 03:31 PM
• Last activity: May 2, 2023, 12:39 PM
1
votes
2
answers
4858
views
Can "at" command execute any kind of shell script?
I created a java program that showed a message dialog. After pressing OK it is closed and the program execution ends. Then I created a shell script `alarm.sh` that executed the program. I tested it and it worked: $ alarm.sh "-i It's time to ring up the revenue service" However when I executed: $ ech...
I created a java program that showed a message dialog. After pressing OK it is closed and the program execution ends.
Then I created a shell script
alarm.sh
that executed the program. I tested it and it worked:
$ alarm.sh "-i It's time to ring up the revenue service"
However when I executed:
$ echo "alarm.sh \"-i It's time to ring up the revenue service\"" | at 15:00
The message dialog didn't pop-up at 15:00 although the job was scheduled. Why? How does "at" execute shell scripts and what are its limitations?
ka3ak
(1275 rep)
Nov 14, 2016, 07:39 PM
• Last activity: Mar 16, 2023, 06:55 PM
2
votes
0
answers
125
views
Listing 'at' jobs with custom time format
Hello I need to list 'at' jobs with the following format **"year-month-day hours:minutes:seconds"**. From the 'at' man page the synopsis I need is the following: ``` at [-V] -l [-o timeformat] [job ...] ``` where timeformat, according to the man page, is "strftime-like time format used for the job l...
Hello I need to list 'at' jobs with the following format **"year-month-day hours:minutes:seconds"**. From the 'at' man page the synopsis I need is the following:
at [-V] -l [-o timeformat] [job ...]
where timeformat, according to the man page, is "strftime-like time format used for the job list". So I tried with the following command:
at -l -o "%y-%m-%d %H:%M:%S"
but keep getting: " at: invalid option -- 'o' "
Centuri0n
(41 rep)
Jan 22, 2023, 03:55 PM
0
votes
0
answers
85
views
Why does the at command not control my wifi via nmcli?
I have `at` installed on Manjaro. This works fine: ``` echo "echo 'hi' > /tmp/greetings" | at now + 1 minutes -M ``` But if I try to switch off my wifi after one minute it doesn't do anything: ``` echo "nmcli d disconnect wlp123s4" | at now + 1 minutes -M ``` Running `nmcli` in the terminal works, e...
I have
at
installed on Manjaro. This works fine:
echo "echo 'hi' > /tmp/greetings" | at now + 1 minutes -M
But if I try to switch off my wifi after one minute it doesn't do anything:
echo "nmcli d disconnect wlp123s4" | at now + 1 minutes -M
Running nmcli
in the terminal works, even from sh
.
journalctl
shows me reason="org.freedesktop.NetworkManager.network-control request failed: not authorized"
.
After seeing https://unix.stackexchange.com/questions/580555/ I checked my /etc/polkit-1/rules.d/99-manjaro.rules
and see no rules related to NetworkManager. Should I add such a rule?
This is for a desktop computer, not a remote server.
aBe
(183 rep)
Jan 2, 2023, 10:49 AM
Showing page 1 of 20 total questions