-
-
Notifications
You must be signed in to change notification settings - Fork 2
Setting Up Automation on Linux
This guide will walk you through the steps to create a shell script that can run multiple Python projects or programs. Additionally, it includes optional steps for opening programs before execution.
-
Open a text editor and create a new file called
run_projects.sh
. -
Add the following lines to the file, replacing
project1
,project2
, andproject3
with the actual names of your Python projects or programs. You can add as many lines as needed for each project or program.#!/bin/bash python -m project1 python -m project2 python -m project3
If you want to open programs before running the Python projects, add the following lines to the script, replacing
program1
andprogram2
with the actual commands to open the programs. You can add as many lines as needed for each program.program1 program2
-
Save the file, for example,
run_projects.sh
.
This section explains how to create a launcher shortcut with an icon for easy on-demand execution of the shell script.
-
Right-click on the desktop and select "Create Launcher" or "Create Shortcut".
-
In the launcher creation dialog, fill in the following information:
- Name: "Run Projects"
- Command: Browse and select the location of the
run_projects.sh
script you created. - Icon: Browse and select an icon file of your choice.
-
Click "OK" or "Create" to save the launcher shortcut.
Now you have a shortcut on your desktop that you can double-click to execute the shell script and run your Python projects or programs (if included). The creation of a shortcut with an icon provides a convenient way to execute the script on demand.
-
Run the Shell Script:
- Double-click the
run_projects.sh
script or the launcher shortcut you created to execute it. This will run the specified Python projects or programs (if included) in the order specified.
- Double-click the
That's it! By following these instructions, you have successfully created a shell script to run multiple Python projects or programs at once, with the option to open programs before execution, and created a shortcut with an icon for easy on-demand execution from the desktop.
This guide will walk you through the steps to configure cron to automatically run any file on login, once per day, or hourly.
-
Open a terminal.
-
Edit the cron table by running the following command:
crontab -e
-
If prompted, choose your preferred text editor.
-
Configure the cron job:
-
To run a file on login:
-
Add the following line to the cron table:
@reboot /path/to/your/file.sh
Replace
/path/to/your/file.sh
with the actual path to the file you want to run on login.
-
-
To run a file once per day:
-
Add the following line to the cron table:
0 0 * * * /path/to/your/file.sh
Replace
/path/to/your/file.sh
with the actual path to the file you want to run once per day.
-
-
To run a file hourly:
-
Add the following line to the cron table:
0 * * * * /path/to/your/file.sh
Replace
/path/to/your/file.sh
with the actual path to the file you want to run hourly.
-
-
-
Save the cron table and exit the text editor.
-
The cron job is now scheduled to run the specified file at the specified time interval.
That's it! You have successfully set up cron to auto-run a file on Linux.