Linux Contrab Texts Girlfriend at 8:00 a.m.

It is said that programmed apes have no girlfriend== sweat, why should we black our handsome programmed apes? Today we are going to do a wave of Linux Contrab timed tasks to send messages to our girlfriend every day.

Here I use the SDK of Ali Bigger's short message. The price of each short message is 0.045 yuan. One dollar is enough for half a month. Meizizzi (?)

Baidu Ali is bigger than, after entering the official website to register an account, and then enter the console, download a wave of SDK, as a PHP, of course, download the SDK of PHP, other SDK can also be downloaded by itself.

After downloading, let's take a look at the directory structure.

This fileTest file is used to send short messages, we need to edit it, but before that, we need to create a short message template in the official website console. There are many tutorials on the official website. After the creation, we edit the so-called fileTest file, open the file and write it.

The following is for my reference only==

#!/usr/bin/php -q
<?php
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$date1 = strtotime('2015-12-23');  //Converting Dates to Timestamps
$date_english = strtotime('2017-06-17');//CET-6 Time
$date2 = time(); //Take the timestamp of the current time
$nowtime=strftime("%y year-%m month-%d day ",$date2); //Format output date
$days=round(($date2-$date1)/3600/24);  //Rounding
$days1=round(($date_english-$date2)/3600/24);//Round off for the remaining days of the English exam
$week=date("N",time()+3600*24);//Judge what day of the week
// $week=7;
$num=mt_rand(0,9);
$num2=mt_rand(0,9);

for($i=0;$i<2;$i++)
{
    if($i==0)
    {
        $name = 'An unconscious girlfriend';
        $c = new TopClient;
        $c ->appkey='';//Write the corresponding key
        $c ->secretKey='';//Write the corresponding key
        $req = new AlibabaAliqinFcSmsNumSendRequest;
        $req ->setExtend( "" );
        $req ->setSmsType( "normal" );
        $req ->setSmsFreeSignName( "SMS signature" );
        $req ->setSmsParam( "{name:'$name',time:'$days',num:'$num'}" );
        $req ->setRecNum( "Your girlfriend's cell phone number" );
        $req ->setSmsTemplateCode( "Short Message Template Number" );
        $resp = $c ->execute( $req );
    }
    else 
    {
        $name = 'Handsome xxx';
        $c = new TopClient;
        $c ->appkey='';//Write the corresponding key
        $c ->secretKey='';//Write the corresponding key
        $req = new AlibabaAliqinFcSmsNumSendRequest;
        $req ->setExtend( "" );
        $req ->setSmsType( "normal" );
        $req ->setSmsFreeSignName( "SMS signature" );
        $req ->setSmsParam( "{name:'$name',time:'$days',num:'$num2'}" );
        $req ->setRecNum( "Your cell phone" );
        $req ->setSmsTemplateCode( "Short Message Template Number" );
        $resp = $c ->execute( $req );
    }
}
?>

After writing, the terminal runs php fileTest.php to test whether it can receive SMS normally. If OK is available, then we will put it on the server and copy the entire folder to the server. Next, we will use the contrab timing task of Linux.

First of all, a brief introduction

With the crontab command, we can execute the specified system instructions or shell script scripts at fixed intervals. The unit of time interval may be any combination of minutes, hours, days, months, weeks or more. This command is very suitable for periodic log analysis or data backup.

Introduce several commands

Contrab-e: Edit the content of a user's crontab file. If no user is specified, it means editing the crontab file of the current user.

Contrab-l: Displays the content of a user's crontab file, and if no user is specified, displays the content of the current user's crontab file.

Introduce the file format of crontab

Commands to be run on time-sharing days, months and weeks

  • Column 1 Minutes 0-59

  • Line 2 Hours 0-23 (0 for midnight)

  • Column 3 Dates 1-31

  • Column 4 - 12

  • Column 5 Weeks 0-7 (0 and 7 means Sunday)

  • Column 6 Commands to Run

For more information http://linuxtools-rst.readthe...

Okay, we just need to know that now, OK.

We run contrab-e on the server

Then add 00 08 * * * php /path/to / your SMS code folder / fileTest.php to the last line of the file. The parameters can be changed by themselves. I'm here at 8:00 every morning. After setting up, run contrab -l to see if the settings have been saved. After all is settled, we can wait for the 8:00 SMS in the morning quietly.

Of course, there are many ways to play, just wait for everyone to play their own Haha ha!

Tags: PHP crontab SDK Linux

Posted on Mon, 03 Jun 2019 18:25:08 -0700 by coolen