0

I know there are many linux experts here, I wish to get little help with at command in Ubuntu. I have been troubled by at command in ubuntu (18.04 and 20.04) for quite a while, but I don't know where I made a mistake. I've tried at on three of my Ubuntu systems and it doesn't work on any of them. at is very handle and nice job scheduler, I really want to get it to work so that I do not have to manually launch programs in the late night on a shared Ubuntu server. I read many tutorials on at command, here is a very good one.

at now + 1 minutes -f ~/myscript.sh, it looks really great and can save me lots of energy. Unfortunately, when myscript.sh is extremely simple,then at now + 1 minutes -f ~/myscript.sh can run smoothly and I get what I expected. Here is everything I have in myscript.sh:

echo $(date) > ~/Desktop/time.txt

On top of that, it never worked for me. For example when I change myscript.sh to

echo $(date) > ~/Desktop/time.txt
pycharm.sh

Basically what myscript.sh does it is noting down the time and to open Pycharm IDE. I can run sh myscript.sh without at , it wroks very well. However, when I run at at now + 1 minutes -f ~/myscript.sh, the time is noted down but Pycharm was not never opened (I can see the process in htop if Pycharm is open). Also at now + 1 minutes -f ~/script.sh does not work with any of my other shell scripts.

Could you please help me understand where I have done wrong and how to make it work. Thank you very much.

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
Albert G Lieu
  • 891
  • 8
  • 16

1 Answers1

0

PyCharm and other GUI programs need a lot of information from your environment. The atd daemon which runs jobs for at does not have access to this environment. You will need to specify it directly.

I recommend running printenv redirected to a file in an at job. Then compare that to printenv running from a terminal in your GUI session. Find the differences and see if you can set them up the same way at the beginning of your at script.

Zan Lynx
  • 53,022
  • 10
  • 79
  • 131
  • Mr Zan, you are right, ````at```` does not seem to have access to all the variables in a normal terminal. I have tried ````source $HOME/.profile```` to, my shell script but it still does not work. DO you know how to add all env variables to ````at````. https://unix.stackexchange.com/a/89596/400554 – Albert G Lieu Mar 26 '21 at 17:27