CRONTAB - automatic file opening - autostart

warpower

New Member
Would like work 'ready-wainting for me'- when the computer boots up.

By work I mean files like docx & other current projects currently worked on.


How can I achieve this with CRONTAB.
 


TechnoJunky

Silver Member
Silver Supporter
Cron is a scheduler. So for instance, if you want to backup your computer every night at midnight, you'd use Cron to schedule that. At the end of your first sentance you say "when the computer boots up", so this isn't scheduled. You have an autostart directory in your home directory. You can place shortcuts in there and when you log in, they will all auto-start. It's located at ~/.config/autostart/. Your desktop environment probably has a GUI for doing it, but where and how is dependant upon which one you have. You can just create shortcuts manually in the directory without the GUI though.
 

warpower

New Member
Kali Linux - autostart is located i which top directory?
/ being root = full path
& how to create those shortcuts in nautilus
 

JasKinasis

Well-Known Member
Roots home directory is in /root
So put your startup files in /root/.config/autostart/

And again - as Technojunky said - just use the terminal to create them. It's far quicker to open a terminal and use the ln command to create a link to the executable you want to run, or write a shellscript in there that will open whatever files you need to have open.
If you're a Kali user - the terminal should be second nature.

And I'm not saying it can't be done via the GUI btw - I just don't use Nautilus - so I can't help you.
There should be a way to do it. Perhaps someone else can help with that. I'd imagine you'd just open (or create) /root/.config/autostart/ - then right click a blank area in the file manager window and select an option in the context menu to create a new link and then you'll be prompted for some details of the link - name, target etc.

Otherwise - just write a script in there that will open whatever programs you want to run at startup.
 

TechnoJunky

Silver Member
Silver Supporter
In Linux, in Terminal, you use the ~/ to point to your own home directory. You don't have to type it all out. It equates to /home/warpower/. If you want something to run automatically when YOU log in, you put it in ~/.config/autostart/. That's the same thing as typing out /home/warpower/.config/autostart/, but no experienced Linux user would type it all out that way unless they were trying to put it in someone else's home directory or script it.
And since you're using Kali, home would be in /root, like JasKinasis stated above.
 
Last edited:

TechnoJunky

Silver Member
Silver Supporter
One thing that I'd suggest is to study up on the Linux Command Line Interface (CLI) which we generally use thru Terminal or a similar tool. Some distros are better for beginners and some are good for more advanced users. Kali is better for advanced users and you're going to need to know your way around the CLI. There's lots of books and information on the net on the subject.
 

warpower

New Member
yo

the files I use are on desktop & there will remain.

now how do i create mentioned shortcut to the file
the CLI command is
?
 

JasKinasis

Well-Known Member
The command to make a symbolic link is ln.

You can create a soft sym-link like this:
Bash:
ln -s -T /path/to/target /path/to/symbolic-link
Where /path/to/target is the path to the target file/executable/script
And /path/to/symbolic-link is the path to and name of the symbolic link.

So if you have a script in your desktop that you want to be ran on startup you can use:
Bash:
ln -s -T /root/Desktop/myscript.sh /root/.config/startup/myscript
And that will create a soft sym-link called "myscript" in /root/.config/startup/ which points to /root/Desktop/myscript.sh.


And if you don't already have a script and the files on your desktop are just files that you are working on - then perhaps you should write a script that will start the associated program/s for each of the files you want opened on startup.
The script should either go in /root/.config/autostart/ - Or put it on your desktop and then create a link to it in the root users autostart directory (as per the above ln example).
e.g.
If you have a bunch of text files on your desktop that you want to open in gvim (or whatever your preferred text editor is) and a pdf file to open with evince at startup:
mystartupscript.sh
Bash:
#!/usr/bin/env bash

gvim /root/Desktop/*.txt &
evince /root/Desktop/HowToRTFM.pdf &
Obviously - you'd substitute in whatever programs/files you want open on startup.
And note the & at the end of each command. That will start the programs in the background. Without that, your startup script wouldn't open evince until gvim has been closed.
So starting the graphical applications in the background will allow the terminal running the script to sequentially start all of the programs.

And don't forget to make your script executable: chmod +x /path/to/mystartupscript.sh
where /path/to/mystartupscript.sh is the path/filename of the script - which will depend on whether you put it in roots startup dir, or on your desktop.....
 
Last edited:

warpower

New Member
Outstanding. Comprehensive. Great writing style conveying much in compact, congested manner.
Wish I talk with more in such a way. & I mean it.

This though, needs clarification. /root/.config/autostart/
Where is such a folder in Kali. Been really looking for it.

& then performed global search with Nautilus, with these results

or do I need to create in /root/.... these folders [config/autostart] manually
 

TechnoJunky

Silver Member
Silver Supporter
In case you're unware, folders that start with . are hidden. So just because you don't see it, doesn't mean it's not there. You need to add -al to your ls command 'ls -al', or enable hidden files in your file manager.
 

Members online


Top