Schedule command using at command

Creating commands

Type in your terminal: at [schedule]

e.g.:

at 10:30 am

Then inside the at command you can type in your commands like:

at> php /var/www/html/yii-application/yii job/my-custom-job param1 param2

Then when you are done adding commands, presst CTRL+D

Deleting commands

If you don't know yet the schedule id, you can execute

atq

It will show you the list of scheduled commands like below:

job 12 at Wed Feb 20 01:00:00 2019

To see the actual command you can execute

at -c 12

To delete the schedule, simply use atrm command with the schedule id like this:

atrm 12

And just in case you were thinking how to close the command that is already running, atrm will not stop the command. Instead you need to kill manually. In your terminal, run:

ps -ef | grep 'YOUR_COMMAND'

It will return something like this:

UID        PID  PPID  C STIME TTY          TIME CMD
root       361     1  0 Oct19 ?        00:00:04 YOUR_COMMAND

Get the PID to kill the command

kill 361