Skip to main content

Run My Script: AIDE and Rkhunter Using Cron

ALL ABOUT PATHS

I have to set my path so the system can "see" or search in the right directory. By default the system will look at the usual directory (/usr/bin;/usr/sbin), I 've decided to put my scripts in my home directory in a folder named scripts. Or just name it bin. I edited my ~/.bash_profile and added this line.

export PATH=$PATH:/path/to/script/directory

While at it and editing this file, you might want to set your text editor of choice. I'm using GNOME so I have gedit and nano.

export EDITOR="$(if [[ -n $DISPLAY ]]; then echo 'gedit'; else echo 'nano'; fi)"

Save and close the file. You need to logout and login to get the changes running. Or you can use the source command. It returns true or an error in your syntax, in which case you should fix it.

$ source ~/.bash_profile



RUN A BASIC SCRIPT

Compose a basic script like printing 'Hello World' in the terminal just to have a feel of running a script. In your text editor type:

#! /bin/bash
#  My first script

echo  "Hello World!"

EOF

Close and save. Then allow permissions and ownership to the file so it can be run by user. Use the commands chown and / or chmod.


INSTALL CRON AND USING CRONTAB

Use pacman to download and install cronie from the main repository. Use systemd to start and enable the service. Cron schedules jobs and automate running processes. By default it sends mail to User when it runs a job in the crontab. Some services are handled by systemd already, for others, User must schedule them.

List of Crontab Commands
crontab -l #list crontabs
crontab -e #edit crontab file in your set EDITOR
crontab -r #removes crontab

Syntax for Crontab jobs
(Minute)0-59 (Hour)0-23 (Day of the Month)1-31 (Month)1-12 (Day of the Week)0-6 command to be executed

A Few Examples:
10 15 * * * /usr/bin/command/ #to run everyday at 3:10 pm

0 0 * * * /home/user/scripts/script-to-run #to run everyday at 12 midnight

I just substitued AIDE and Rkhunter scripts on this crontab examples. Now it's all in the scripts.

Comments

Popular posts from this blog

Password Issues On Ubuntu Login

I found myself unable to enter my login credentials when prompted to do so in Ubuntu. I think I might have changed it then forget about it. I've been running the current session for more days than I should have. I forget. So what's the solution to my problem. How do I get in to my system now? It involved getting into the grub menu somehow. I am uncertain as to how to do that exactly in your system. So there's a couple of ways to do it (finger's crossed). When booting at system start, use the esc key or the shift key. The first one worked for me. The timing is key. Wait until the bios banner shows then hit the esc key once. I am using Ubuntu 22.04.4 here. I have a current version of grub. The grub menu will give you options and the one you want is: root. Yes you want root privileges to set the root password. It should give you a terminal access where you can issue commands. Type: #mount -rw -o -s remount / ==> this command mounts the filesyste...

New ZFS Pool And the New 4TB Hard Drive

I am using the new pool for my videos and music. Downloading them using my torrent client, transmission. The old pool is raidz2 and now I am using a raidz1 only. But and a big but I gained space of up to 4.5 TB.

2024 So Far

I have a feeling of moving earth or walking off my itchiness. The growing fat in my belly tells me I am failing on many occasions to give in to this urge. My eyes are blurred by morning glory. I remember my father having the same ritual in the morning. After his weak stroke, he couldn't speak much, just a grunt but he would demonstrate with hand how he liked to wash his face. The weather wasn't helping. It's been raining cats and dogs the past week. The province of Rizal was soaked and spilled volumes of water into the bay and Laguna lake. Our Caimito tree was cut to no more than 4 feet from the ground. It was towering above the corrugated sheet metal of our roof. Now it lay horizontal on the yard. I calculated it could be made into a whole table and chairs set by a talented carpenter artist. I showed Lino the two big pieces of trunk that could only be moved if cut by a power saw in place. The road widening project in San Mateo was in the middle stage. One side of the road ...