1

I wrote a python script and added it to the list of startup applications in Ubuntu. After restarting the device I can find that the script has not run and I don't know where to find the logs. What is the default location in which the logs will be stored?

I searched around similar questions such as this.I don't think this will apply for me as I am using a different method than the one mentioned in the question.

EDIT : I did not add my script in rc.local or as a cron job. In ubuntu dash if you type startup you will get a window asking you to add commands that you want to execute on startup. I added my script in that window.

Nirmal Raj
  • 171
  • 1
  • 1
  • 6
  • How do you autostart your script - using `/etc/rc.local` or `/etc/ini.d/script_name`? – M. Dm. Jan 02 '18 at 12:12
  • @M.Dm. In ubuntu dash if you type startup you will get a window asking you to add commands that you want to execute on startup. I added my script in that window. – Nirmal Raj Jan 02 '18 at 12:53
  • Could you please [edit] your post, when you want to clarify something or add information? It’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks. – David Foerster Jan 03 '18 at 09:35
  • What *exact* command did you add to the list of start-up applications? How *exactly* did you verify that the program didn't run? There is no log file location for applications that aren't set up to generate them. – David Foerster Jan 03 '18 at 09:38
  • @DavidFoerster I added `python3 ...\main.py` to the list and if the program ran it is supposed to show a notification but I didn't get any. You can see my code here.https://github.com/RajNirmal/Python_Remainder/blob/master/main.py. I added a couple of `print()` lines in there but haven't updated the repo yet. The output of the `print()` function should be stored somewhere right? – Nirmal Raj Jan 03 '18 at 09:40
  • Please verify that the *absolute* path to the Python program exists, e. g. with `ls -l ...\main.py`. Did you really use backslashes (`\ `) as path component delimiter? Linux and other Unix-like operating systems use forward slashes (`/`) for that. Again, please **[edit]** your post to add additional information so that future readers don't have to scour the comment section for it. – David Foerster Jan 03 '18 at 09:44

1 Answers1

2

After you added your python script to startup applications, a new '.desktop' file - corresponding to your script - have appeared in ~/.config/autostart That file contains a line saying: Exec=your_script.py

A simple workaround would be to change in the .desktop file your_script.py to wrapper.sh, where wrapper.sh would be a new script simply reading: python your_script.py > your_log.txt

Then, obviously, the output of your_script.py will appear in your_log.txt.

P.S. I would have added this workaround as a comment rather, than a solution, which I cannot do as a newly registered user. Sorry about that, hope it helps.

Maciek
  • 141
  • 6