I want to display message in terminal:
"Welcome!"
when someone opens the terminal
To print a message when opening a terminal (or logging in via ssh) you should use the message of the day (/etc/motd).
You could use cron to overwrite this file at specific times, and so users will see the current message when they log in:
00 1 * * * "/bin/echo 'Good morning' > /etc/motd"
00 12 * * * "/bin/echo 'Good afternoon' > /etc/motd"
00 17 * * * "/bin/echo 'Good evening' > /etc/motd"
Related
I have some cronjobs written on several servers using CentOS7 in combination with Plesk 18.
When I check my cron log I see that the cronjobs are started.
Even when I manually start the scripts I want to use they work, but for some reason when the crontab does it, nothing is happening.
For instance some of the cronjobs I have are:
MAILTO=support#shoptrader.nl
0 0 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/remove_files.sh
0 6 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/security_htaccess/security_htaccess.sh
15 7 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/backup_personal_files.sh
30 9 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_hacks/find_hacks.sh
*/5 * * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh
15 0 * * * sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/backup_templates_data/backup_templates_data.sh
If I check my log I see something like: Jan 14 09:30:01 web14 CROND[4402]: (root) CMD (sh /var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh)
I've notified myself with e-mails and get this response
/var/www/vhosts/upgrade14.shoptrader.com/httpdocs/find_sql_injection/find_sql_injection.sh: line 12: php: command not found.
Which doesn't make sense, because PHP is working on the server.
I have to run task which take time 3 or 5 minut
How to run multiple task in crontab -in same time ?
crontab -e
0 13 * * * /etc/rip_first_radio.sh
0 13 * * * /etc/rip_second_radio.sh
0 13 * * * /etc/rip_third_radio.sh
0 13 * * * /etc/rip_fourth_radio.sh
your crontab config is correct. But you can add add all into one script and run also.
vi main.sh
./etc/rip_first_radio.sh &
./etc/rip_second_radio.sh &
./etc/rip_third_radio.sh &
./etc/rip_fourth_radio.sh &
and add main.sh to cron.
0 13 * * * ./main.sh
I am testing an sh script with crontab which simply creates a file
#!/bin/bash
PATH=$PATH:/bin:/usr/bin
TMP_FILE=/home/hmm/AppFlatForRent/i_am_running
touch "$TMP_FILE"
Now I want to run it on crontab and have used the following but failed
18 10 * * * sh /home/hmm/AppFlatForRent/hello.sh
Also this one
18 10 * * * usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
I am also trying this
23 12 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
23 12 * * * /home/hmm/AppFlatForRent/hello2.sh
Anyone knows whats the problem?
Solution:
23 12 * * * sh /home/hmm/AppFlatForRent/hello1.sh
This works!
Give the full path to the shell from cron starting with '/':
18 10 * * * /usr/bin/sh /home/hmm/AppFlatForRent/hello.sh
Or just leave the shell out and run the script directly if it is executable:
18 10 * * * /home/hmm/AppFlatForRent/hello.sh
I have 2 crontab commands.
The cron below works fine:
00 19 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare
The cron below does not work after I add the time behind:
05 09 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare/'date +%Y%m%d%H%M%S'cyn.in-disk1.vmdk
Please guide me to understand the command and how to solve.
You should enclose the date command with ` instead of ' and escape the % characters
Try this:
05 09 * * * cp -a /home/kmportal/VirtualBox\ VMs/cyn.in-disk1.vmdk /media/windowsshare/`date +\%Y\%m\%d\%H\%M\%S`cyn.in-disk1.vmdk
I know that crontab job emails output of the job to its user. In my crontab file I have multiple jobs like:
10 21 * * * test1.sh
13 21 * * * test2.sh
0 * * * * test3.sh
I don't want to receive email for test3.sh. Does below code works? I want to make sure that only for the last job I wont receive email.
10 21 * * * test1.sh
13 21 * * * test2.sh
MAILTO=""
0 * * * * test3.sh
See http://www.cyberciti.biz/faq/disable-the-mail-alert-by-crontab-command/
You could use something like
0 * * * * test3.sh >/dev/null 2>&1
There will be no output --> no mail sent.